A large start value is probably worse performing than the sort (see SOLR-1726). Once the sort field is cached, it'll be quick from then on. Put in a warming query in solrconfig for new and/or firstSearcher that does this sort and the cache will be built in advance of queries at least.
Erik On Jun 13, 2012, at 16:09 , Jack Krupansky wrote: > Try the query without the sort to get the number of rows, then do a second > query using a "start" equal to the number of rows. That should get you the > last row/document. > > -- Jack Krupansky > > -----Original Message----- From: rafal.gwizd...@gmail.com > Sent: Wednesday, June 13, 2012 3:07 PM > To: solr-user@lucene.apache.org > Subject: Getting maximum / minimum field value - slow query > > Hi, I have an index with about 9 millions of documents. Every document has an > integer 'Id' field (it's not the SOLR document identifier) and I want to get > the maximum value of that field. > Therefore I'm doing a search with the following parameters > query=*.*, sort=Id desc, rows=1 > > <response> > <lst name="responseHeader"> > <int name="status">0</int> > <int name="QTime">2672</int> > <lst name="params"> > <str name="q">*:*</str> > <str name="rows">1</str> > <str name="sort">Id desc</str> > </lst> > </lst> > <result name="response" numFound="8747779" start="0"> > <doc> > <str name="Uid">CRQIncident#45165891</str> > </doc> > </result> > </response> > > The problem is that it takes quite a long time to get the response (2-10 > seconds). Why is it so slow - isn't it a simple index lookup? > > Best regards > RG > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Getting-maximum-minimum-field-value-slow-query-tp3989467.html > Sent from the Solr - User mailing list archive at Nabble.com.