# Searching for negative numbers very slow

6 messages
Open this post in threaded view
|

## Searching for negative numbers very slow

 If I do         qt=dismax     fq=uid:1 (or any other positive number) then queries are as quick as normal - in the 20ms range. However, any of         fq=uid:\-1 or     fq=uid:[* TO -1] or         fq=uid:[-1 to -1] or     fq=-uid:[0 TO *] then queries are incredibly slow - in the 9 *second* range. Anything I can do to mitigate this? Negative numbers have significant meaning in our system so it wouldn't be trivial to shift all uids up by the number of negative ids. Thanks, Simon
Open this post in threaded view
|

## Re: Searching for negative numbers very slow

 On Thu, Jan 27, 2011 at 11:32:26PM +0000, me said: > If I do > > qt=dismax >     fq=uid:1 > > (or any other positive number) then queries are as quick as normal - in > the 20ms range. For what it's worth uid is a TrieIntField with precisionStep=0, omitNorms=true, positionIncrementGap=0
Open this post in threaded view
|

## Re: Searching for negative numbers very slow

 In reply to this post by Simon Wistow On Thu, Jan 27, 2011 at 6:32 PM, Simon Wistow <[hidden email]> wrote: > If I do > >        qt=dismax >    fq=uid:1 > > (or any other positive number) then queries are as quick as normal - in > the 20ms range. > > However, any of > >        fq=uid:\-1 > > or > >    fq=uid:[* TO -1] > > or > >    fq=uid:[-1 to -1] > > or > >    fq=-uid:[0 TO *] > > then queries are incredibly slow - in the 9 *second* range. That's odd - there should be nothing special about negative numbers. Here are a couple of ideas:   - if you have a really big index and querying by a negative number is much more rare, it could just be that part of the index wasn't cached by the OS and so the query needs to hit the disk.  This can happen with any term and a really big index - nothing special for negatives here.  - if -1 is a really common value, it can be slower.  is fq=uid:\-2 or other negative numbers really slow also? -Yonik http://lucidimagination.com
Open this post in threaded view
|

## Re: Searching for negative numbers very slow

 On Fri, Jan 28, 2011 at 12:29:18PM -0500, Yonik Seeley said: > That's odd - there should be nothing special about negative numbers. > Here are a couple of ideas: >   - if you have a really big index and querying by a negative number > is much more rare, it could just be that part of the index wasn't > cached by the OS and so the query needs to hit the disk.  This can > happen with any term and a really big index - nothing special for > negatives here. >  - if -1 is a really common value, it can be slower.  is fq=uid:\-2 or > other negative numbers really slow also? This was my first thought but -1 is relatively common but we have other numbers just as common. Interestingly enough fq=uid:-1 fq=foo:bar fq=alpha:omega is much (4x) slower than q="uid:-1 AND foo:bar AND alpha:omega" but only when searching for that number. I'm going to wave my hands here and say something like "Maybe something to do with the field caches?"