我试图了解语句缓存在参数化准备语句的情况下是否有用。
据我的理解
我正在使用 JDBC/Snaq DB Pool/ MySQL 数据库。
这里的Statement Caching指的是两种不同的情况:
我的困惑很简单:
希望我能澄清我的问题。
我需要找出一个标签与另一组固定标签作为整体之间的共现时间。我有 10000 个不同的单个标签,固定标签集中有 10k 个标签。我以固定的时间范围循环访问一组固定标签上下文下的所有单个标签。我的索引内总共有 10 亿个文档,有 20 个分片。
这是elasticsearch查询,elasticsearch 6.6.0:
es.search(index=index, size=0, body={
"query": {
"bool": {
"filter": [
{"range": {
"created_time": {
"gte": fixed_start_time,
"lte": fixed_end_time,
"format": "yyyy-MM-dd-HH"
}}},
{"term": {"tags": dynamic_single_tag}},
{"terms": {"tags": {
"index" : "fixed_set_tags_list",
"id" : 2,
"type" : "twitter",
"path" : "tag_list"
}}}
]
}
}, "aggs": {
"by_month": {
"date_histogram": {
"field": "created_time",
"interval": "month",
"min_doc_count": 0,
"extended_bounds": {
"min": two_month_start_time,
"max": start_month_start_time}
}}}
})
Run Code Online (Sandbox Code Playgroud)
我的问题:是否有任何解决方案可以在elasticsearch内部有一个缓存,用于固定的10k组标签术语查询和时间范围过滤器,从而可以加快查询时间?对于我上面的查询,单个标签花费了 1.5 秒。
我已使用此查询检查了查询缓存的状态SHOW VARIABLES LIKE ‘%query_cache%’;.同样是有任何查询或命令来检查的值query_cache_type.任何帮助将受到高度赞赏.