You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Lars Kotthoff <la...@larsko.org> on 2008/05/11 10:04:32 UTC

AND vs. OR query performance

Dear list,

 during some performance experiments I have found that queries with ORed search
terms are significantly faster than queries with ANDed search terms, everything
else being equal.

Does anybody know whether this is the generally expected behaviour?

Thanks,

Lars

Re: AND vs. OR query performance

Posted by Lars Kotthoff <la...@larsko.org>.
Thanks for the clarification. The behaviour I'm seeing is that OR queries are
almost *twice* as performant as AND queries, so that's probably down to my
specific setup/data. I'll try to investigate further.

Lars

On Mon, 12 May 2008 19:35:00 -0400
"Yonik Seeley" <yo...@apache.org> wrote:

> In general, AND will perform better than OR (because of skipping in
> the scorers).  But if the number of documents matching the AND is
> close to that matching the OR query, then skipping doesn't gain you
> much and probably has a little more overhead.
> 
> -Yonik
> 
> On Sun, May 11, 2008 at 4:04 AM, Lars Kotthoff <la...@larsko.org> wrote:
> > Dear list,
> >
> >   during some performance experiments I have found that queries with ORed search
> >  terms are significantly faster than queries with ANDed search terms, everything
> >  else being equal.
> >
> >  Does anybody know whether this is the generally expected behaviour?
> >
> >  Thanks,
> >
> >  Lars
> >
> 

Re: AND vs. OR query performance

Posted by Yonik Seeley <yo...@apache.org>.
In general, AND will perform better than OR (because of skipping in
the scorers).  But if the number of documents matching the AND is
close to that matching the OR query, then skipping doesn't gain you
much and probably has a little more overhead.

-Yonik

On Sun, May 11, 2008 at 4:04 AM, Lars Kotthoff <la...@larsko.org> wrote:
> Dear list,
>
>   during some performance experiments I have found that queries with ORed search
>  terms are significantly faster than queries with ANDed search terms, everything
>  else being equal.
>
>  Does anybody know whether this is the generally expected behaviour?
>
>  Thanks,
>
>  Lars
>