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.
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:should-matchcondition will match over 500 documents, and the query value keeps changing, due to theshouldclause, it won't be cached byQueryCache.filter-termswill match over 100,000,000 documents, theuser_typehas several fixed values, it will also not be cached because of theskipCacheFactor(100,000,000 / skipCacheFactor > 500).lucene/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
Line 773 in 067b472
There seem to be several points for optimization:
QueryCacheis not full utilized, can we loosen the restrictions to cache more queries that don't meet the current conditions?skip_factorofQueryCache. Alternatively, this parameter could be deprecated, If a query meetsminFrequencyToCache, meaning it is frequent, it should be placed intoQueryCache.Furthermore, if user were able to dynamically adjust
maxSize,maxRamBytesUsedinQueryCache, considering that the overhead of such adjustments is rather small.