Web / Apache Solr Interview questions
How do you troubleshoot slow Solr queries?
Diagnosing slow queries in Solr is mostly a process of isolating which stage of the request is expensive.
- Add
debugQuery=trueand inspect thetimingblock in the response - it breaks down time spent per component (query, facet, highlight). - Check the admin UI's Query tab and cache statistics - a low hit ratio on the filter or query result cache means repeated work that could be reduced with better
fqreuse or larger cache sizes. - Review the field types involved - sorting or faceting on a field without
docValuesforces an expensive uninverted field cache to build on first use. - Look at wildcard and leading-wildcard queries (e.g.
*term) - these can't use the index efficiently and often scan far more terms than expected. - Check deep pagination - a high
startvalue forces Solr to compute and discard many results before returning the requested page.
Most real-world slowness traces back to one of these five causes rather than needing more hardware, so profiling before scaling out saves both time and infrastructure cost.
More Related questions...