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 Maulin Rathod <mr...@asite.com> on 2015/08/19 07:55:25 UTC

Performance issue with FILTER QUERY

Hi,

http://stackoverflow.com/questions/11627427/solr-query-q-or-filter-query-fq

As per above link it suggests to use Filter Query but we observed Filter Query is slower than Normal Query in our case. Are we doing something wrong?


SLOW WITH FILTER QUERY (takes more than 1 second)
============================================

q=+recipient_id:(4042) AND project_id:(332) AND resource_id:(13332247 13332245 13332243 13332241 13332239) AND entity_type:(2) AND -action_id:(20 32) ==> This returns 5 records
fq=+action_status:(0) AND is_active:(true) ==> This Filter Query returns 9432252 records

Final result is 0 records.

FAST WITHOUT FILTER QUERY (takes less than 10 millisecond)
==============================================

q=+recipient_id:( 4042) AND project_id:( 332) AND resource_id:(13332247 13332245 13332243 13332241 13332239) AND entity_type:(2) AND -action_id:(20 32) AND +action_status:(0) AND is_active:(true)==> This returns 0  records

Final result is 0 records.





Regards,

Maulin

[CC Award Winners 2014]


RE: Performance issue with FILTER QUERY

Posted by Maulin Rathod <mr...@asite.com>.
Thanks Erick. Even 1 second commit interval is fine for us. But in that case also filter cache will be flushed after 1 sec. The end user will still feel slowness due to this as the query will take around 1 sec if we use filter query.

-----Original Message-----
From: Erick Erickson [mailto:erickerickson@gmail.com] 
Sent: 20 August 2015 00:44
To: solr-user@lucene.apache.org
Subject: Re: Performance issue with FILTER QUERY

If you're committing that rapidly then you're correct, filter caching may not be a good fit. The entire _point_ of filter caching is to increase performance of subsequent executions of the exact same fq clause. But if you're throwing them away every second there's little/no benefit.

You really have two choices here
1> lengthen out the commit interval. Frankly, 1 second commit
intervals are rarely necessary despite what
     your product manager says. Really, check this requirement out.
2> disable caches.

Autowarming is potentially useful here, but if your filter queries are taking on the order of a second and you're committing every second then autowarming takes too long to help.

Best,
Erick

On Wed, Aug 19, 2015 at 12:26 AM, Mikhail Khludnev <mk...@griddynamics.com> wrote:
> Maulin,
> Did you check performance with segmented filters which I advised recently?
>
> On Wed, Aug 19, 2015 at 10:24 AM, Maulin Rathod <mr...@asite.com> wrote:
>
>> As per my understanding caches are flushed every time when add new 
>> document to collection (we do soft commit at every 1 sec to make 
>> newly added document available for search). Due to which it is not 
>> effectively uses cache and hence it slow every time in our case.
>>
>> -----Original Message-----
>> From: Toke Eskildsen [mailto:te@statsbiblioteket.dk]
>> Sent: 19 August 2015 12:16
>> To: solr-user@lucene.apache.org
>> Subject: Re: Performance issue with FILTER QUERY
>>
>> On Wed, 2015-08-19 at 05:55 +0000, Maulin Rathod wrote:
>> > SLOW WITH FILTER QUERY (takes more than 1 second) 
>> > ============================================
>> >
>> > q=+recipient_id:(4042) AND project_id:(332) AND 
>> > resource_id:(13332247
>> > 13332245 13332243 13332241 13332239) AND entity_type:(2) AND
>> > -action_id:(20 32) ==> This returns 5 records
>> > fq=+action_status:(0) AND is_active:(true) ==> This Filter Query 
>> > returns 9432252 records
>>
>> The fq is evaluated independently of the q: For the fq a bitset is 
>> allocated, filled and stored in cache. Then the q is evaluated and 
>> the two bitsets are merged.
>>
>> Next time you use the same fq, it should be cached (if you have 
>> caching
>> enabled) and be a lot faster.
>>
>>
>> Also, if you ran your two tests right after each other, the second 
>> one benefits from disk caching. If you had executed them in reverse 
>> order, the
>> q+fq might have been the fastest one.
>>
>> - Toke Eskildsen, State and University Library, Denmark
>>
>>
>>
>
>
> --
> Sincerely yours
> Mikhail Khludnev
> Principal Engineer,
> Grid Dynamics
>
> <http://www.griddynamics.com>
> <mk...@griddynamics.com>

Re: Performance issue with FILTER QUERY

Posted by Erick Erickson <er...@gmail.com>.
If you're committing that rapidly then you're correct, filter caching
may not be a good fit. The entire _point_ of
filter caching is to increase performance of subsequent executions of
the exact same fq clause. But if you're
throwing them away every second there's little/no benefit.

You really have two choices here
1> lengthen out the commit interval. Frankly, 1 second commit
intervals are rarely necessary despite what
     your product manager says. Really, check this requirement out.
2> disable caches.

Autowarming is potentially useful here, but if your filter queries are
taking on the order of a second and
you're committing every second then autowarming takes too long to help.

Best,
Erick

On Wed, Aug 19, 2015 at 12:26 AM, Mikhail Khludnev
<mk...@griddynamics.com> wrote:
> Maulin,
> Did you check performance with segmented filters which I advised recently?
>
> On Wed, Aug 19, 2015 at 10:24 AM, Maulin Rathod <mr...@asite.com> wrote:
>
>> As per my understanding caches are flushed every time when add new
>> document to collection (we do soft commit at every 1 sec to make newly
>> added document available for search). Due to which it is not effectively
>> uses cache and hence it slow every time in our case.
>>
>> -----Original Message-----
>> From: Toke Eskildsen [mailto:te@statsbiblioteket.dk]
>> Sent: 19 August 2015 12:16
>> To: solr-user@lucene.apache.org
>> Subject: Re: Performance issue with FILTER QUERY
>>
>> On Wed, 2015-08-19 at 05:55 +0000, Maulin Rathod wrote:
>> > SLOW WITH FILTER QUERY (takes more than 1 second)
>> > ============================================
>> >
>> > q=+recipient_id:(4042) AND project_id:(332) AND resource_id:(13332247
>> > 13332245 13332243 13332241 13332239) AND entity_type:(2) AND
>> > -action_id:(20 32) ==> This returns 5 records
>> > fq=+action_status:(0) AND is_active:(true) ==> This Filter Query
>> > returns 9432252 records
>>
>> The fq is evaluated independently of the q: For the fq a bitset is
>> allocated, filled and stored in cache. Then the q is evaluated and the two
>> bitsets are merged.
>>
>> Next time you use the same fq, it should be cached (if you have caching
>> enabled) and be a lot faster.
>>
>>
>> Also, if you ran your two tests right after each other, the second one
>> benefits from disk caching. If you had executed them in reverse order, the
>> q+fq might have been the fastest one.
>>
>> - Toke Eskildsen, State and University Library, Denmark
>>
>>
>>
>
>
> --
> Sincerely yours
> Mikhail Khludnev
> Principal Engineer,
> Grid Dynamics
>
> <http://www.griddynamics.com>
> <mk...@griddynamics.com>

Re: Performance issue with FILTER QUERY

Posted by Mikhail Khludnev <mk...@griddynamics.com>.
Maulin,
Did you check performance with segmented filters which I advised recently?

On Wed, Aug 19, 2015 at 10:24 AM, Maulin Rathod <mr...@asite.com> wrote:

> As per my understanding caches are flushed every time when add new
> document to collection (we do soft commit at every 1 sec to make newly
> added document available for search). Due to which it is not effectively
> uses cache and hence it slow every time in our case.
>
> -----Original Message-----
> From: Toke Eskildsen [mailto:te@statsbiblioteket.dk]
> Sent: 19 August 2015 12:16
> To: solr-user@lucene.apache.org
> Subject: Re: Performance issue with FILTER QUERY
>
> On Wed, 2015-08-19 at 05:55 +0000, Maulin Rathod wrote:
> > SLOW WITH FILTER QUERY (takes more than 1 second)
> > ============================================
> >
> > q=+recipient_id:(4042) AND project_id:(332) AND resource_id:(13332247
> > 13332245 13332243 13332241 13332239) AND entity_type:(2) AND
> > -action_id:(20 32) ==> This returns 5 records
> > fq=+action_status:(0) AND is_active:(true) ==> This Filter Query
> > returns 9432252 records
>
> The fq is evaluated independently of the q: For the fq a bitset is
> allocated, filled and stored in cache. Then the q is evaluated and the two
> bitsets are merged.
>
> Next time you use the same fq, it should be cached (if you have caching
> enabled) and be a lot faster.
>
>
> Also, if you ran your two tests right after each other, the second one
> benefits from disk caching. If you had executed them in reverse order, the
> q+fq might have been the fastest one.
>
> - Toke Eskildsen, State and University Library, Denmark
>
>
>


-- 
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<mk...@griddynamics.com>

RE: Performance issue with FILTER QUERY

Posted by Maulin Rathod <mr...@asite.com>.
As per my understanding caches are flushed every time when add new document to collection (we do soft commit at every 1 sec to make newly added document available for search). Due to which it is not effectively uses cache and hence it slow every time in our case.
 
-----Original Message-----
From: Toke Eskildsen [mailto:te@statsbiblioteket.dk] 
Sent: 19 August 2015 12:16
To: solr-user@lucene.apache.org
Subject: Re: Performance issue with FILTER QUERY

On Wed, 2015-08-19 at 05:55 +0000, Maulin Rathod wrote:
> SLOW WITH FILTER QUERY (takes more than 1 second) 
> ============================================
> 
> q=+recipient_id:(4042) AND project_id:(332) AND resource_id:(13332247 
> 13332245 13332243 13332241 13332239) AND entity_type:(2) AND 
> -action_id:(20 32) ==> This returns 5 records
> fq=+action_status:(0) AND is_active:(true) ==> This Filter Query 
> returns 9432252 records

The fq is evaluated independently of the q: For the fq a bitset is allocated, filled and stored in cache. Then the q is evaluated and the two bitsets are merged.

Next time you use the same fq, it should be cached (if you have caching
enabled) and be a lot faster.


Also, if you ran your two tests right after each other, the second one benefits from disk caching. If you had executed them in reverse order, the q+fq might have been the fastest one.

- Toke Eskildsen, State and University Library, Denmark



Re: Performance issue with FILTER QUERY

Posted by Toke Eskildsen <te...@statsbiblioteket.dk>.
On Wed, 2015-08-19 at 05:55 +0000, Maulin Rathod wrote:
> SLOW WITH FILTER QUERY (takes more than 1 second)
> ============================================
> 
> q=+recipient_id:(4042) AND project_id:(332) AND resource_id:(13332247 13332245 13332243 13332241 13332239) AND entity_type:(2) AND -action_id:(20 32) ==> This returns 5 records
> fq=+action_status:(0) AND is_active:(true) ==> This Filter Query returns 9432252 records

The fq is evaluated independently of the q: For the fq a bitset is
allocated, filled and stored in cache. Then the q is evaluated and the
two bitsets are merged.

Next time you use the same fq, it should be cached (if you have caching
enabled) and be a lot faster.


Also, if you ran your two tests right after each other, the second one
benefits from disk caching. If you had executed them in reverse order,
the q+fq might have been the fastest one.

- Toke Eskildsen, State and University Library, Denmark



Re: Performance issue with FILTER QUERY

Posted by Mikhail Khludnev <mk...@griddynamics.com>.
Hello,

try to experiment with fq={!cache=false}... or fq={!cache=false cost=100}...
see https://cwiki.apache.org/confluence/display/solr/Common+Query+Parameters

On Wed, Aug 19, 2015 at 8:55 AM, Maulin Rathod <mr...@asite.com> wrote:

>
> Hi,
>
> http://stackoverflow.com/questions/11627427/solr-query-q-or-filter-query-fq
>
> As per above link it suggests to use Filter Query but we observed Filter
> Query is slower than Normal Query in our case. Are we doing something wrong?
>
>
> SLOW WITH FILTER QUERY (takes more than 1 second)
> ============================================
>
> q=+recipient_id:(4042) AND project_id:(332) AND resource_id:(13332247
> 13332245 13332243 13332241 13332239) AND entity_type:(2) AND -action_id:(20
> 32) ==> This returns 5 records
> fq=+action_status:(0) AND is_active:(true) ==> This Filter Query returns
> 9432252 records
>
> Final result is 0 records.
>
> FAST WITHOUT FILTER QUERY (takes less than 10 millisecond)
> ==============================================
>
> q=+recipient_id:( 4042) AND project_id:( 332) AND resource_id:(13332247
> 13332245 13332243 13332241 13332239) AND entity_type:(2) AND -action_id:(20
> 32) AND +action_status:(0) AND is_active:(true)==> This returns 0  records
>
> Final result is 0 records.
>
>
>
>
>
> Regards,
>
> Maulin
>
> [CC Award Winners 2014]
>
>


-- 
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<mk...@griddynamics.com>