SELECT checksum AS `checksum`,
LEFT(dimension.sample,20) AS `snippet`,
ROUND(SUM(Rows_examined_sum)/SUM(rows_sent_sum),2) AS `index_ratio`,
SUM(Query_time_sum) / SUM(ts_cnt) AS `query_time_avg`,
ROUND(SUM(Rows_sent_sum)/SUM(ts_cnt),0) AS `rows_sent_avg`,
SUM(ts_cnt) AS `ts_cnt`,
SUM(Query_time_sum) AS `Query_time_sum`,
SUM(Lock_time_sum) AS `Lock_time_sum`,
SUM(Rows_sent_sum) AS `Rows_sent_sum`,
SUM(Rows_examined_sum) AS `Rows_examined_sum`,
SUM(Tmp_table_sum) AS `Tmp_table_sum`,
SUM(Filesort_sum) AS `Filesort_sum`,
SUM(Full_scan_sum) AS `Full_scan_sum`
FROM `global_query_review` AS `fact`
JOIN `global_query_review_history` AS `dimension` USING (`checksum`)
WHERE dimension.ts_min >= "2024-02-12 05:06:11"
AND dimension.ts_min <= "2024-02-13 05:06:11"
GROUP BY checksum
ORDER BY Query_time_sum DESC
LIMIT 20