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 vishal patel <vi...@outlook.com> on 2019/05/10 13:32:14 UTC

Solr query takes a too much time in Solr 6.1.0

We have 2 shards and 2 replicas in Live environment. we have multiple collections.
Some times some query takes much time(QTime=52552).  There are so many documents indexing and searching within milliseconds.
When we executed the same query again using admin panel, it does not take a much time and it completes within 20 milliseconds.

My Solr Logs :
2019-05-10 09:48:56.744 INFO  (qtp1239731077-128223) [c:actionscomments s:shard1 r:core_node1 x:actionscomments] o.a.s.c.S.Request [actionscomments]  webapp=/solr path=/select params={q=%2Bproject_id:(2102117)%2Brecipient_id:(4642365)+%2Bentity_type:(1)+-action_id:(20+32)+%2Baction_status:(0)+%2Bis_active:(true)+%2B(is_formtype_active:true)+%2B(appType:1)&shards=s1.example.com:8983/solr/actionscomments|s1r1.example.com:8983/solr/actionscomments,s2.example.com:8983/solr/actionscomments|s2r1.example.com:8983/solr/actionscomments&indent=off&shards.tolerant=true&fl=id&start=0&sort=id+desc,id+desc&fq=&rows=1} hits=198 status=0 QTime=52552
2019-05-10 09:48:56.744 INFO  (qtp1239731077-127998) [c:actionscomments s:shard1 r:core_node1 x:actionscomments] o.a.s.c.S.Request [actionscomments]  webapp=/solr path=/select params={q=%2Bproject_id:(2102117)%2Brecipient_id:(4642365)+%2Bentity_type:(1)+-action_id:(20+32)+%2Baction_status:(0)+%2Bis_active:(true)+%2Bdue_date:[2019-05-09T19:30:00Z+TO+2019-05-09T19:30:00Z%2B1DAY]+%2B(is_formtype_active:true)+%2B(appType:1)&shards=s1.example.com:8983/solr/actionscomments|s1r1.example.com:8983/solr/actionscomments,s2.example.com:8983/solr/actionscomments|s2r1.example.com:8983/solr/actionscomments&indent=off&shards.tolerant=true&fl=id&start=0&sort=id+desc,id+desc&fq=&rows=1} hits=0 status=0 QTime=51970
2019-05-10 09:48:56.746 INFO  (qtp1239731077-128224) [c:actionscomments s:shard1 r:core_node1 x:actionscomments] o.a.s.c.S.Request [actionscomments]  webapp=/solr path=/select params={q=%2Bproject_id:(2121600+2115171+2104206)%2Brecipient_id:(2834330)+%2Bentity_type:(2)+-action_id:(20+32)+%2Baction_status:(0)+%2Bis_active:(true)+%2Bdue_date:[2019-05-10T00:00:00Z+TO+2019-05-10T00:00:00Z%2B1DAY]&shards=s1.example.com:8983/solr/actionscomments|s1r1.example.com:8983/solr/actionscomments,s2.example.com:8983/solr/actionscomments|s2r1.example.com:8983/solr/actionscomments&indent=off&shards.tolerant=true&fl=id&start=0&sort=id+desc,id+desc&fq=&rows=1} hits=98 status=0 QTime=51402


My schema fields below :

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false"/>
<field name="project_id" type="tint" indexed="true" stored="true"/>
<field name="recipient_id" type="tint" indexed="true" stored="true"/>
<field name="entity_type" type="tint" indexed="true" stored="true"/>
<field name="action_id" type="tint" indexed="true" stored="true"/>
<field name="action_status" type="tint" indexed="true" stored="true"/>
<field name="is_active" type="boolean" indexed="true" stored="true" />
<field name="is_formtype_active" type="boolean" indexed="true" stored="true" />
<field name="appType" type="tint" indexed="true" stored="true" />
<field name="due_date" type="date" indexed="true" stored="true"/>

What could be a problem here? why the query takes too much time at that time?

Sent from Outlook<http://aka.ms/weboutlook>

Re: Solr query takes a too much time in Solr 6.1.0

Posted by Shawn Heisey <ap...@elyograg.org>.
On 5/13/2019 2:51 AM, vishal patel wrote:
>> Executing an identical query again will likely satisfy the query from Solr's caches.  Solr won't need to talk to the actual index, and it will be REALLY fast.  Even a massively complex query, if it is cached, will be fast.
> 
> All caches are disabled in our schema file because of our indexing and searching ratio is high in our live environment.

Solr's caches are defined in solrconfig.xml, not the schema.  I mention 
this so you can be sure you have the config you think you have.

If your caches are in fact disabled, I am betting that the index data 
relevant to that query is getting pushed out of your OS disk cache. 
When you execute the same query twice, all the data required by Lucene 
to execute that query is available in the OS disk cache, so the second 
time is quick because Lucene is pulling the information from RAM, which 
is MUCH faster than disk.

Fixing that usually requires adding more memory to the server.

Thanks,
Shawn

Re: Solr query takes a too much time in Solr 6.1.0

Posted by vishal patel <vi...@outlook.com>.
Thanks for the reply.

> Executing an identical query again will likely satisfy the query from Solr's caches.  Solr won't need to talk to the actual index, and it will be REALLY fast.  Even a massively complex query, if it is cached, will be fast.

All caches are disabled in our schema file because of our indexing and searching ratio is high in our live environment.


Sent from Outlook<http://aka.ms/weboutlook>
________________________________
From: Shawn Heisey <ap...@elyograg.org>
Sent: Friday, May 10, 2019 9:32 PM
To: solr-user@lucene.apache.org
Subject: Re: Solr query takes a too much time in Solr 6.1.0

On 5/10/2019 7:32 AM, vishal patel wrote:
> We have 2 shards and 2 replicas in Live environment. we have multiple collections.
> Some times some query takes much time(QTime=52552).  There are so many documents indexing and searching within milliseconds.

There could be any number of causes of slow performance.

A common reason is not having enough spare memory in the machine to
allow the operating system to cache the index data.  This is memory NOT
allocated by programs (including Solr).

Another common reason is that the heap size is too small, which causes
Java to frequently perform full garbage collections, which will REALLY
kill performance.

Since there's very little information here, it's difficult for us to
diagnose the cause.  Here's a wiki page about performance problems:

https://wiki.apache.org/solr/SolrPerformanceProblems

(Disclaimer:  I am the principal author of that page)

> When we executed the same query again using admin panel, it does not take a much time and it completes within 20 milliseconds.

Executing an identical query again will likely satisfy the query from
Solr's caches.  Solr won't need to talk to the actual index, and it will
be REALLY fast.  Even a massively complex query, if it is cached, will
be fast.

Running the information from your logs through a URL decoder, this is
what I found:

q=+project_id:(2102117)+recipient_id:(4642365) +entity_type:(1)
-action_id:(20 32) +action_status:(0) +is_active:(true)
+(is_formtype_active:true) +(appType:1)

If all of those fields are indexed, then I would not expect a properly
sized server to be slow.  If any of those fields are indexed=false and
have docValues, then it could be a schema configuration issue.
Searching docValues does work, but it's really slow.

Your query does have an empty fq ... "fq=" ... I do not know whether
that's problematic.  Try it without that to verify.  I would not expect
it to cause problems, but I can't be sure.

Thanks,
Shawn

Re: Solr query takes a too much time in Solr 6.1.0

Posted by Shawn Heisey <ap...@elyograg.org>.
On 5/10/2019 7:32 AM, vishal patel wrote:
> We have 2 shards and 2 replicas in Live environment. we have multiple collections.
> Some times some query takes much time(QTime=52552).  There are so many documents indexing and searching within milliseconds.

There could be any number of causes of slow performance.

A common reason is not having enough spare memory in the machine to 
allow the operating system to cache the index data.  This is memory NOT 
allocated by programs (including Solr).

Another common reason is that the heap size is too small, which causes 
Java to frequently perform full garbage collections, which will REALLY 
kill performance.

Since there's very little information here, it's difficult for us to 
diagnose the cause.  Here's a wiki page about performance problems:

https://wiki.apache.org/solr/SolrPerformanceProblems

(Disclaimer:  I am the principal author of that page)

> When we executed the same query again using admin panel, it does not take a much time and it completes within 20 milliseconds.

Executing an identical query again will likely satisfy the query from 
Solr's caches.  Solr won't need to talk to the actual index, and it will 
be REALLY fast.  Even a massively complex query, if it is cached, will 
be fast.

Running the information from your logs through a URL decoder, this is 
what I found:

q=+project_id:(2102117)+recipient_id:(4642365) +entity_type:(1) 
-action_id:(20 32) +action_status:(0) +is_active:(true) 
+(is_formtype_active:true) +(appType:1)

If all of those fields are indexed, then I would not expect a properly 
sized server to be slow.  If any of those fields are indexed=false and 
have docValues, then it could be a schema configuration issue. 
Searching docValues does work, but it's really slow.

Your query does have an empty fq ... "fq=" ... I do not know whether 
that's problematic.  Try it without that to verify.  I would not expect 
it to cause problems, but I can't be sure.

Thanks,
Shawn

Re: Solr query takes a too much time in Solr 6.1.0

Posted by David Hastings <ha...@gmail.com>.
first inclination is your index is cold.

On Fri, May 10, 2019 at 9:32 AM vishal patel <vi...@outlook.com>
wrote:

> We have 2 shards and 2 replicas in Live environment. we have multiple
> collections.
> Some times some query takes much time(QTime=52552).  There are so many
> documents indexing and searching within milliseconds.
> When we executed the same query again using admin panel, it does not take
> a much time and it completes within 20 milliseconds.
>
> My Solr Logs :
> 2019-05-10 09:48:56.744 INFO  (qtp1239731077-128223) [c:actionscomments
> s:shard1 r:core_node1 x:actionscomments] o.a.s.c.S.Request
> [actionscomments]  webapp=/solr path=/select
> params={q=%2Bproject_id:(2102117)%2Brecipient_id:(4642365)+%2Bentity_type:(1)+-action_id:(20+32)+%2Baction_status:(0)+%2Bis_active:(true)+%2B(is_formtype_active:true)+%2B(appType:1)&shards=
> s1.example.com:8983/solr/actionscomments|s1r1.example.com:8983/solr/actionscomments,s2.example.com:8983/solr/actionscomments|s2r1.example.com:8983/solr/actionscomments&indent=off&shards.tolerant=true&fl=id&start=0&sort=id+desc,id+desc&fq=&rows=1
> <http://s1.example.com:8983/solr/actionscomments%7Cs1r1.example.com:8983/solr/actionscomments,s2.example.com:8983/solr/actionscomments%7Cs2r1.example.com:8983/solr/actionscomments&indent=off&shards.tolerant=true&fl=id&start=0&sort=id+desc,id+desc&fq=&rows=1>}
> hits=198 status=0 QTime=52552
> 2019-05-10 09:48:56.744 INFO  (qtp1239731077-127998) [c:actionscomments
> s:shard1 r:core_node1 x:actionscomments] o.a.s.c.S.Request
> [actionscomments]  webapp=/solr path=/select
> params={q=%2Bproject_id:(2102117)%2Brecipient_id:(4642365)+%2Bentity_type:(1)+-action_id:(20+32)+%2Baction_status:(0)+%2Bis_active:(true)+%2Bdue_date:[2019-05-09T19:30:00Z+TO+2019-05-09T19:30:00Z%2B1DAY]+%2B(is_formtype_active:true)+%2B(appType:1)&shards=
> s1.example.com:8983/solr/actionscomments|s1r1.example.com:8983/solr/actionscomments,s2.example.com:8983/solr/actionscomments|s2r1.example.com:8983/solr/actionscomments&indent=off&shards.tolerant=true&fl=id&start=0&sort=id+desc,id+desc&fq=&rows=1
> <http://s1.example.com:8983/solr/actionscomments%7Cs1r1.example.com:8983/solr/actionscomments,s2.example.com:8983/solr/actionscomments%7Cs2r1.example.com:8983/solr/actionscomments&indent=off&shards.tolerant=true&fl=id&start=0&sort=id+desc,id+desc&fq=&rows=1>}
> hits=0 status=0 QTime=51970
> 2019-05-10 09:48:56.746 INFO  (qtp1239731077-128224) [c:actionscomments
> s:shard1 r:core_node1 x:actionscomments] o.a.s.c.S.Request
> [actionscomments]  webapp=/solr path=/select
> params={q=%2Bproject_id:(2121600+2115171+2104206)%2Brecipient_id:(2834330)+%2Bentity_type:(2)+-action_id:(20+32)+%2Baction_status:(0)+%2Bis_active:(true)+%2Bdue_date:[2019-05-10T00:00:00Z+TO+2019-05-10T00:00:00Z%2B1DAY]&shards=
> s1.example.com:8983/solr/actionscomments|s1r1.example.com:8983/solr/actionscomments,s2.example.com:8983/solr/actionscomments|s2r1.example.com:8983/solr/actionscomments&indent=off&shards.tolerant=true&fl=id&start=0&sort=id+desc,id+desc&fq=&rows=1
> <http://s1.example.com:8983/solr/actionscomments%7Cs1r1.example.com:8983/solr/actionscomments,s2.example.com:8983/solr/actionscomments%7Cs2r1.example.com:8983/solr/actionscomments&indent=off&shards.tolerant=true&fl=id&start=0&sort=id+desc,id+desc&fq=&rows=1>}
> hits=98 status=0 QTime=51402
>
>
> My schema fields below :
>
> <field name="id" type="string" indexed="true" stored="true"
> required="true" multiValued="false"/>
> <field name="project_id" type="tint" indexed="true" stored="true"/>
> <field name="recipient_id" type="tint" indexed="true" stored="true"/>
> <field name="entity_type" type="tint" indexed="true" stored="true"/>
> <field name="action_id" type="tint" indexed="true" stored="true"/>
> <field name="action_status" type="tint" indexed="true" stored="true"/>
> <field name="is_active" type="boolean" indexed="true" stored="true" />
> <field name="is_formtype_active" type="boolean" indexed="true"
> stored="true" />
> <field name="appType" type="tint" indexed="true" stored="true" />
> <field name="due_date" type="date" indexed="true" stored="true"/>
>
> What could be a problem here? why the query takes too much time at that
> time?
>
> Sent from Outlook<http://aka.ms/weboutlook>
>