To compare metrics between two queries, you must first obtain the query_id
for both queries.
You can then run the following query:
WITH
initial_query_id = '9bc1b438-542e-450a-8284-0e3e2b3739c8' AS second,
initial_query_id = '4ce13192-2849-48f9-b426-e04790c4f4aa' AS first
SELECT
PE.1 AS metric,
sumIf(PE.2, first) AS v1,
sumIf(PE.2, second) AS v2,
10 * log10(v2 / v1) AS dB,
round(((v2 - v1) / if(v2 > v1, v2, v1)) * 100, 2) AS perc,
bar(abs(perc), 0, 100, 33) AS bar
FROM clusterAllReplicas(default, system.query_log)
ARRAY JOIN ProfileEvents AS PE
WHERE (first OR second) AND (event_date >= (today() - 3)) AND (type = 2)
GROUP BY metric
HAVING (v1 != v2) AND (abs(perc) >= 0)
ORDER BY
dB DESC,
v2 DESC,
metric ASC
FORMAT PrettyCompactMonoBlock
You will receive a table with metrics comparing the two queries:
ββmetricβββββββββββββββββββββββββββββββββββββββββββββββ¬βββββββv1ββ¬βββββββv2ββ¬ββββββββββββββββββdBββ¬βββpercββ¬βbarββββββββββββββββββββββββββββββββ
β OSReadBytes β 0 β 528384 β inf β 100 β βββββββββββββββββββββββββββββββββ β
β OSIOWaitMicroseconds β 0 β 10000 β inf β 100 β βββββββββββββββββββββββββββββββββ β
β QueryProfilerRuns β 0 β 1 β inf β 100 β βββββββββββββββββββββββββββββββββ β
β RealTimeMicroseconds β 51019 β 980061 β 12.835211655165127 β 94.79 β ββββββββββββββββββββββββββββββββ β
β WaitPrefetchTaskMicroseconds β 24 β 322 β 11.276446299842249 β 92.55 β βββββββββββββββββββββββββββββββ β
β ConcurrencyControlSlotsAcquired β 5 β 59 β 10.718820073061256 β 91.53 β βββββββββββββββββββββββββββββββ β
β DiskReadElapsedMicroseconds β 752 β 8549 β 10.556974764896038 β 91.2 β ββββββββββββββββββββββββββββββ β
β CachedReadBufferReadFromCacheMicroseconds β 767 β 8597 β 10.495515627892747 β 91.08 β ββββββββββββββββββββββββββββββ β
β RemoteFSUnusedPrefetches β 2 β 15 β 8.750612633917001 β 86.67 β βββββββββββββββββββββββββββββ β
β SelectedMarksTotal β 87545 β 634063 β 8.599010641264753 β 86.19 β βββββββββββββββββββββββββββββ β
β ThreadpoolReaderSubmitReadSynchronouslyMicroseconds β 1614 β 10335 β 8.064069505772554 β 84.38 β ββββββββββββββββββββββββββββ β
β ThreadpoolReaderTaskMicroseconds β 1614 β 10335 β 8.064069505772554 β 84.38 β ββββββββββββββββββββββββββββ β
β FilesystemCacheLockKeyMicroseconds β 17 β 89 β 7.18941085266639 β 80.9 β βββββββββββββββββββββββββββ β
β GlobalThreadPoolLockWaitMicroseconds β 28 β 135 β 6.831757371527869 β 79.26 β βββββββββββββββββββββββββββ β
β LocalThreadPoolLockWaitMicroseconds β 17 β 80 β 6.7264106561366965 β 78.75 β ββββββββββββββββββββββββββ β
β RowsReadByPrewhereReaders β 106496 β 483328 β 6.569086593353074 β 77.97 β ββββββββββββββββββββββββββ β
β FileSegmentUseMicroseconds β 9 β 40 β 6.478174818886375 β 77.5 β ββββββββββββββββββββββββββ β
β LocalThreadPoolShrinks β 17 β 74 β 6.387827983527022 β 77.03 β ββββββββββββββββββββββββββ β
β LocalThreadPoolExpansions β 21 β 78 β 5.698753079565612 β 73.08 β ββββββββββββββββββββββββ β
β GlobalThreadPoolJobs β 22 β 79 β 5.552044104682352 β 72.15 β ββββββββββββββββββββββββ β
β SoftPageFaults β 910 β 3078 β 5.292272231743663 β 70.44 β ββββββββββββββββββββββββ β
β LocalThreadPoolThreadCreationMicroseconds β 195 β 651 β 5.23546377205674 β 70.05 β βββββββββββββββββββββββ β
β SelectedBytes β 3415687 β 11339579 β 5.211188641615589 β 69.88 β βββββββββββββββββββββββ β
β FileSegmentHolderCompleteMicroseconds β 7 β 23 β 5.1662979600333605 β 69.57 β βββββββββββββββββββββββ β
β SystemTimeMicroseconds β 10124 β 32525 β 5.068651687474073 β 68.87 β βββββββββββββββββββββββ β
β CompressedReadBufferBytes β 2840805 β 8641987 β 4.831721849930746 β 67.13 β βββββββββββββββββββββββ β
β CompressedReadBufferBlocks β 37 β 101 β 4.361196497156476 β 63.37 β βββββββββββββββββββββ β
β OSCPUWaitMicroseconds β 167 β 434 β 4.147732583649274 β 61.52 β βββββββββββββββββββββ β
β SelectedRows β 106496 β 262144 β 3.9120662601306924 β 59.38 β ββββββββββββββββββββ β
β SelectedMarks β 13 β 32 β 3.9120662601306924 β 59.38 β ββββββββββββββββββββ β
β RowsReadByMainReader β 85341 β 209657 β 3.9035163966363244 β 59.29 β ββββββββββββββββββββ β
β LocalThreadPoolJobs β 72 β 173 β 3.8071360669752696 β 58.38 β ββββββββββββββββββββ β
β OSCPUVirtualTimeMicroseconds β 30914 β 74149 β 3.7995009576328758 β 58.31 β ββββββββββββββββββββ β
β ThreadpoolReaderSubmitLookupInCacheMicroseconds β 594 β 1324 β 3.4810154012248757 β 55.14 β βββββββββββββββββββ β
β FilesystemCacheGetOrSetMicroseconds β 244 β 535 β 3.40963955682499 β 54.39 β ββββββββββββββββββ β
β UserTimeMicroseconds β 20850 β 42076 β 3.049283871282462 β 50.45 β βββββββββββββββββ β
β FileSegmentWaitReadBufferMicroseconds β 698 β 1336 β 2.8195103551636573 β 47.75 β ββββββββββββββββ β
β CachedReadBufferCreateBufferMicroseconds β 679 β 1298 β 2.8140491818384876 β 47.69 β ββββββββββββββββ β
β CachedReadBufferReadFromCacheHits β 36 β 68 β 2.762064119389491 β 47.06 β ββββββββββββββββ β
β ReadBufferFromFileDescriptorRead β 36 β 68 β 2.762064119389491 β 47.06 β ββββββββββββββββ β
β RemoteFSPrefetches β 36 β 68 β 2.762064119389491 β 47.06 β ββββββββββββββββ β
β ThreadpoolReaderSubmitReadSynchronously β 36 β 68 β 2.762064119389491 β 47.06 β ββββββββββββββββ β
β BackgroundLoadingMarksTasks β 27 β 50 β 2.6760624017703147 β 46 β ββββββββββββββββ β
β MarkCacheHits β 27 β 50 β 2.6760624017703147 β 46 β ββββββββββββββββ β
β OpenedFileCacheMicroseconds β 38 β 70 β 2.6531444339744663 β 45.71 β βββββββββββββββ β
β FileOpen β 18 β 33 β 2.632414347745814 β 45.45 β βββββββββββββββ β
β OpenedFileCacheMisses β 18 β 33 β 2.632414347745814 β 45.45 β βββββββββββββββ β
β IOBufferAllocBytes β 41297957 β 74846517 β 2.5824302741078133 β 44.82 β βββββββββββββββ β
β IOBufferAllocs β 57 β 99 β 2.3976033892505857 β 42.42 β ββββββββββββββ β
β MetadataFromKeeperCacheHit β 180 β 300 β 2.2184874961635637 β 40 β ββββββββββββββ β
β CreatedReadBufferOrdinary β 36 β 60 β 2.2184874961635637 β 40 β ββββββββββββββ β
β FilesystemCacheHoldFileSegments β 36 β 60 β 2.2184874961635637 β 40 β ββββββββββββββ β
β FilesystemCacheUnusedHoldFileSegments β 36 β 60 β 2.2184874961635637 β 40 β ββββββββββββββ β
β RemoteFSBuffers β 36 β 60 β 2.2184874961635637 β 40 β ββββββββββββββ β
β Seek β 36 β 60 β 2.2184874961635637 β 40 β ββββββββββββββ β
β FunctionExecute β 147 β 233 β 2.0003858627784283 β 36.91 β βββββββββββββ β
β RemoteFSPrefetchedReads β 34 β 53 β 1.9279695255853393 β 35.85 β ββββββββββββ β
β OpenedFileCacheHits β 18 β 27 β 1.7609125905568124 β 33.33 β βββββββββββ β
β PartsLockHoldMicroseconds β 7 β 10 β 1.5490195998574317 β 30 β ββββββββββ β
β LoggerElapsedNanoseconds β 3611832 β 5131283 β 1.5249842605281847 β 29.61 β ββββββββββ β
β RemoteFSSeeks β 55 β 77 β 1.46128035678238 β 28.57 β ββββββββββ β
β OSWriteChars β 40188 β 54666 β 1.3362090343407957 β 26.48 β βββββββββ β
β ContextLock β 245 β 329 β 1.2802981358544177 β 25.53 β βββββββββ β
β OSReadChars β 483965 β 611174 β 1.0135091568962058 β 20.81 β βββββββ β
β OSWriteBytes β 16384 β 20480 β 0.9691001300805642 β 20 β βββββββ β
β SelectedParts β 12 β 15 β 0.9691001300805642 β 20 β βββββββ β
β SelectedPartsTotal β 12 β 15 β 0.9691001300805642 β 20 β βββββββ β
β SelectedRanges β 12 β 15 β 0.9691001300805642 β 20 β βββββββ β
β LogTrace β 60 β 74 β 0.9108046934733258 β 18.92 β βββββββ β
β LogDebug β 17 β 20 β 0.7058107428570727 β 15 β βββββ β
β CachedReadBufferReadFromCacheBytes β 448770 β 526207 β 0.6913280420090238 β 14.72 β βββββ β
β ReadBufferFromFileDescriptorReadBytes β 448770 β 526207 β 0.6913280420090238 β 14.72 β βββββ β
β RemoteFSPrefetchedBytes β 448770 β 526207 β 0.6913280420090238 β 14.72 β βββββ β
β ThreadpoolReaderReadBytes β 448770 β 526207 β 0.6913280420090238 β 14.72 β βββββ β
β ThreadpoolReaderSubmitReadSynchronouslyBytes β 448770 β 526207 β 0.6913280420090238 β 14.72 β βββββ β
β WaitMarksLoadMicroseconds β 348 β 305 β -0.5727940459979509 β -12.36 β ββββ β
β ArenaAllocBytes β 49152 β 40960 β -0.7918124604762482 β -16.67 β ββββββ β
β ArenaAllocChunks β 12 β 10 β -0.7918124604762482 β -16.67 β ββββββ β
β ReadCompressedBytes β 441904 β 344814 β -1.0774304213935042 β -21.97 β ββββββββ β
β FilesystemCacheLockMetadataMicroseconds β 23 β 17 β -1.3127891463931898 β -26.09 β βββββββββ β
β ConcurrencyControlQueriesDelayed β 1 β 0 β -inf β -100 β βββββββββββββββββββββββββββββββββ β
β ConcurrencyControlSlotsDelayed β 54 β 0 β -inf β -100 β βββββββββββββββββββββββββββββββββ β
β ContextLockWaitMicroseconds β 8 β 0 β -inf β -100 β βββββββββββββββββββββββββββββββββ β
β FileSegmentFailToIncreasePriority β 1 β 0 β -inf β -100 β βββββββββββββββββββββββββββββββββ β
β ThreadpoolReaderPrepareMicroseconds β 8 β 0 β -inf β -100 β βββββββββββββββββββββββββββββββββ β
ββmetricβββββββββββββββββββββββββββββββββββββββββββββββ΄βββββββv1ββ΄βββββββv2ββ΄ββββββββββββββββββdBββ΄βββpercββ΄βbarββββββββββββββββββββββββββββββββ
85 rows in set. Elapsed: 0.074 sec. Processed 2.16 million rows, 102.28 MB (29.19 million rows/s., 1.38 GB/s.)
Peak memory usage: 114.84 MiB.