# Performance problem in Percolator fetch phase classes

**URL:** <https://discuss.elastic.co/t/performance-problem-in-percolator-fetch-phase-classes/243748>\
**Category:** Elasticsearch\
**Created:** [August 4, 2020, 3:58pm UTC](https://discuss.elastic.co/t/performance-problem-in-percolator-fetch-phase-classes/243748 "2020-08-04T15:58:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apeteri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/apeteri/32/73326_2.png) [@apeteri](https://discuss.elastic.co/u/apeteri)\
**Post date:** [August 4, 2020, 3:58pm UTC](https://discuss.elastic.co/t/performance-problem-in-percolator-fetch-phase-classes/243748/1 "2020-08-04T15:58:20Z")

</div>

Hi,

We are using Elasticsearch 7.8.0 and seem to be encountering a performance issue that we traced back to the method `PercolatorHighlightSubFetchPhase#locatePercolatorQuery`. Lucene 8.6 introduced a change to `QueryVisitor` as well as `TermInSetQuery` [1] that results in `visitLeaf` being called for each matching term in the index; this can become very costly even during "non-percolating" queries, and at this point `PercolatorHighlightSubFetchPhase` is only figuring out whether to run at all [2]. In addition to that, `PercolatorMatchedSlotSubFetchPhase` re-uses this very same method [3].

Did anyone else encounter similar problems, is this worthy of a bug report on GitHub?

Regards,  
András

[1] [https://github.com/apache/lucene-solr/pull/1465](https://github.com/apache/lucene-solr/pull/1465)  
[2] [https://github.com/elastic/elasticsearch/blob/master/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorHighlightSubFetchPhase.java#L56](https://github.com/elastic/elasticsearch/blob/master/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorHighlightSubFetchPhase.java#L56)  
[3] [https://github.com/elastic/elasticsearch/blob/master/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorMatchedSlotSubFetchPhase.java#L66](https://github.com/elastic/elasticsearch/blob/master/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorMatchedSlotSubFetchPhase.java#L66)

---

<div class="post-metadata">

**Author:** ![apeteri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/apeteri/32/73326_2.png) [@apeteri](https://discuss.elastic.co/u/apeteri)\
**Post date:** [August 5, 2020, 7:46am UTC](https://discuss.elastic.co/t/performance-problem-in-percolator-fetch-phase-classes/243748/2 "2020-08-05T07:46:49Z")

</div>

Correction: the linked Lucene PR might help resolving this problem, as it changes `TermInSetQuery` so that it resolves terms lazily when visited by a `QueryVisitor`.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 2, 2020, 7:46am UTC](https://discuss.elastic.co/t/performance-problem-in-percolator-fetch-phase-classes/243748/3 "2020-09-02T07:46:50Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
