2023-01-26 22:23:10 +00:00
|
|
|
-- Tags: no-parallel
|
|
|
|
-- Tag no-parallel: Messes with internal cache
|
|
|
|
|
|
|
|
-- Start with empty query cache (QC).
|
|
|
|
SYSTEM DROP QUERY CACHE;
|
|
|
|
|
|
|
|
-- By default, don't write query result into QC.
|
|
|
|
SELECT 1;
|
|
|
|
SELECT COUNT(*) FROM system.query_cache;
|
|
|
|
|
|
|
|
SELECT '-----';
|
|
|
|
|
|
|
|
-- Try to retrieve query from empty QC using the passive mode. Do this by disabling the active mode. The cache should still be empty (no insert).
|
|
|
|
SELECT 1 SETTINGS use_query_cache = true, enable_writes_to_query_cache = false;
|
|
|
|
SELECT COUNT(*) FROM system.query_cache;
|
|
|
|
|
|
|
|
SELECT '-----';
|
|
|
|
|
|
|
|
-- Put query into cache.
|
|
|
|
SELECT 1 SETTINGS use_query_cache = true;
|
|
|
|
SELECT COUNT(*) FROM system.query_cache;
|
|
|
|
|
|
|
|
SELECT '-----';
|
|
|
|
|
2023-06-13 14:15:30 +00:00
|
|
|
/* Run same query with passive mode again. There must still be one entry in the QC and we must have a QC hit. */
|
2023-01-26 22:23:10 +00:00
|
|
|
|
|
|
|
SELECT 1 SETTINGS use_query_cache = true, enable_writes_to_query_cache = false;
|
|
|
|
SELECT COUNT(*) FROM system.query_cache;
|
|
|
|
|
|
|
|
SYSTEM FLUSH LOGS;
|
|
|
|
SELECT ProfileEvents['QueryCacheHits'], ProfileEvents['QueryCacheMisses']
|
|
|
|
FROM system.query_log
|
|
|
|
WHERE type = 'QueryFinish'
|
2023-06-13 14:15:30 +00:00
|
|
|
AND current_database = currentDatabase()
|
|
|
|
/* NOTE: client incorrectly join comments from the previous line into query, hence LIKE */
|
|
|
|
AND query LIKE '%\nSELECT 1 SETTINGS use_query_cache = true, enable_writes_to_query_cache = false;'
|
|
|
|
ORDER BY event_time_microseconds;
|
2023-01-26 22:23:10 +00:00
|
|
|
|
|
|
|
SYSTEM DROP QUERY CACHE;
|