[Xapian-discuss] Fwd: Re: what is the fastest way to fetch results which are sorted by timestamp ?

Tim Brody tdb2 at ecs.soton.ac.uk
Thu Aug 11 09:55:47 BST 2011


On Thu, 11 Aug 2011 09:04:33 +0100, Richard Boulton <richard at tartarus.org>
wrote:
> On 11 August 2011 08:49, Tim Brody <tdb2 at ecs.soton.ac.uk> wrote:
>>> set_weighting_scheme(Xapian::BoolWeight());
>>> set_docid_order(Xapian::Enquire::DESCENDING);
>>
>> In my test, it is more than 10 times slower than :
>>
>> set_weighting_scheme(Xapian::BoolWeight());
>> set_docid_order(Xapian::Enquire::ASCENDING);
>>
>> Why?
> 
> The xapian indexes for each term are stored in ascending order of
> document ID.  When performing a search, all the indexes for the terms
> involved in the query are iterated through in parallel, in ascending
> order of document ID.  If the BoolWeight scheme is in use (or, more
> generally, if the maximum weight that can be returned is 0), and the
> result docid order is ASCENDING, as soon as sufficient matching
> documents have been found the match process can stop, without getting
> to the end of the indexes.
> 
> Unfortunately, it is not possible to iterate through the indexes in
> reverse order, so if the order is DESCENDING, the match process has to
> run to the end of the indexes, in order to find out what the last N
> items were.  This is obviously quite a bit slower.

I took that example from here:
http://xapian.org/docs/apidoc/html/classXapian_1_1Enquire.html#bbf7ff734ff6adcb301e493f6eed803b

Which says reverse-sorting by docid is "very efficient" ?

-- 
All the best,
Tim.



More information about the Xapian-discuss mailing list