Skip to content

Optimizing use the QueryCache #14028

@kkewwei

Description

@kkewwei

Description

In my use-case, I discover the utilization percentage of QueryCache(with a capacity of 3GB and only 50MB used) is extremely low. Most of the queries are as follows:

POST index1/_search
{
   "size": 300,
   "query": {
      "bool": {
         "filter": [
            {
               "terms": {
                  "user_type": [0, 1, 3, 5, 4, 6]
               }
            }
         ],
         "should": [
            {
               "match": {
                  "name_ik": {
                     "query": "ab cd ed gh",
                     "operator": "OR",
                     "analyzer": "ik_max_word",
                  }
               }
            }
         ]
      }
   }
}
  • should-match condition will match over 500 documents, and the query value keeps changing, due to the should clause, it won't be cached by QueryCache.
  • filter-terms will match over 100,000,000 documents, the user_type has several fixed values, it will also not be cached because of the skipCacheFactor(100,000,000 / skipCacheFactor > 500).
    if (cost / skipCacheFactor > leadCost) {

There seem to be several points for optimization:

  • When the utilization percentage of QueryCache is not full utilized, can we loosen the restrictions to cache more queries that don't meet the current conditions?
  • User could be allowed to dynamically modify the skip_factor of QueryCache. Alternatively, this parameter could be deprecated, If a query meets minFrequencyToCache, meaning it is frequent, it should be placed into QueryCache.

Furthermore, if user were able to dynamically adjust maxSize, maxRamBytesUsed in QueryCache, considering that the overhead of such adjustments is rather small.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions