Solr Performance - Ask for Fewer Rows and Fields

Account Resources

The cheapest Solr optimisation is asking for less: fewer rows, and only the fields the page shows.

A search result page shows ten or twenty results. A request for a thousand costs a thousand documents read from disk, decompressed, cached and serialized, on every single call. The numbers below are one query against one of our own indexes, changing nothing but rows.

RESPONSE BYTES FOR ONE QUERYrows=10rows=100rows=100010.7 KB103.8 KB1,053.5 KBSame query, same matches, same index. Only the rows parameter changed.

Ten times the rows is ten times the payload, ten times the decompression and ten times the cache pressure.

RequestResponse sizeWhat it costs on the server
rows=1010,766 bytesTen documents materialized. A normal search page.
rows=100103,790 bytesStill reasonable. This is the sensible ceiling for a page.
rows=10001,053,533 bytesA megabyte per request, plus a documentCache entry for every document.

Keep rows under 100 for anything a user looks at, and always send an fl list. A field list is the cheapest optimisation available: a result page that shows a title, a price and a link has no reason to transport the full body text of every document.

GET /solr/mycore/select
  ?q=running shoes
  &rows=20
  &fl=id,title,price,url
Returning fields you do not display is also what you pay for in transfer: Opensolr bills the bytes your index sends back, not the number of queries. The same change fixes both problems — see Solr traffic bandwidth and how to save transfer bandwidth.

Solr best practices

Ask for fewer rows and fields (this page)