What's Actually Happening
Solr queries take too long to execute. Search response times are high, affecting application performance.
The Error You'll See
```bash $ curl "http://localhost:8983/solr/mycore/select?q=*:*"
# Response time > 5 seconds ```
Why This Happens
- 1.No proper schema optimization
- 2.Missing or inefficient indexes
- 3.Cache misconfiguration
- 4.Large result sets
- 5.Complex queries
Step 1: Check Query Performance
curl "http://localhost:8983/solr/mycore/select?q=*:*&debugQuery=true"Step 2: Check Index Stats
curl "http://localhost:8983/solr/mycore/admin/luke"
curl "http://localhost:8983/solr/mycore/admin/stats"Step 3: Optimize Schema
<!-- schema.xml -->
<field name="title" type="text_general" indexed="true" stored="true"/>
<field name="content" type="text_general" indexed="true" stored="false"/>Step 4: Configure Caches
<!-- solrconfig.xml -->
<query>
<filterCache class="solr.FastLRUCache" size="512" initialSize="512" autowarmCount="0"/>
<queryResultCache class="solr.LRUCache" size="512" initialSize="512" autowarmCount="0"/>
<documentCache class="solr.LRUCache" size="512" initialSize="512" autowarmCount="0"/>
</query>Step 5: Use Filter Queries
# Instead of:
q=title:search AND category:books
# Use:
q=title:search&fq=category:booksStep 6: Limit Fields
# Only return needed fields
q=*:*&fl=id,titleStep 7: Use Pagination
q=*:*&rows=10&start=0Step 8: Commit and Optimize
curl "http://localhost:8983/solr/mycore/update?commit=true"
curl "http://localhost:8983/solr/mycore/update?optimize=true"Step 9: Check Resources
free -m
top -bn1 | head -20Step 10: Monitor Query Time
curl "http://localhost:8983/solr/mycore/admin/mbeans?cat=QUERY&stats=true"Related Issues
- [Fix Solr Index Not Updating](/articles/fix-solr-index-not-updating)
- [Fix Elasticsearch Query Timeout](/articles/fix-elasticsearch-query-timeout)