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

Richard Boulton richard at tartarus.org
Thu Aug 11 09:04:33 BST 2011


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.

-- 
Richard



More information about the Xapian-discuss mailing list