Skip to content

Instantly share code, notes, and snippets.

@systay
Created November 11, 2024 08:05
Show Gist options
  • Save systay/c96fd8ccc1f23d0c89887e643bc910ba to your computer and use it in GitHub Desktop.
Save systay/c96fd8ccc1f23d0c89887e643bc910ba to your computer and use it in GitHub Desktop.

Query Analysis Report

Date of Analysis: 2024-01-01 01:02:03
Analyzed File: testdata/keys-log.json


Hot Queries

Query Execution Count Total Time (s) Avg Time (ms) % of Total Time
SELECT * FROM orders WHERE order_date > ?; 1,200 480 400 24%
SELECT l_orderkey FROM lineitem WHERE l_shipdate < ?; 1,500 450 300 22.5%
UPDATE customer SET c_name = ? WHERE c_custkey = ?; 800 320 400 16%
INSERT INTO supplier (s_name, s_address) VALUES (?, ?); 500 200 400 10%
DELETE FROM part WHERE p_partkey = ?; 300 120 400 6%
Other Queries 430 21.5%
Total 4,300 2,000 100%

Note: The "Other Queries" row aggregates all remaining queries not listed individually.


Tables

Overview

Table Name Reads Writes Total Time (s) % of Total Time
lineitem 17 1 650 32.5%
orders 11 1 500 25%
customer 7 1 350 17.5%
supplier 8 1 250 12.5%
part 5 1 150 7.5%
nation 10 1 80 4%
partsupp 4 1 15 0.75%
region 2 1 5 0.25%
Total 2,000 100%

Note: The "Total Time (s)" column reflects the cumulative time spent on queries involving each table.


Column Usage with Timing

Table: lineitem (17 reads and 1 write, Total Time: 650s)

Column Position Used % Total Time (s) % of Table Time
l_orderkey JOIN 72% 468 72%
GROUP 17% 110 17%
l_suppkey JOIN 39% 254 39%
JOIN RANGE 17% 110 17%
l_shipdate WHERE RANGE 33% 215 33%
l_commitdate WHERE RANGE 28% 182 28%
l_receiptdate WHERE RANGE 28% 182 28%
l_partkey JOIN 17% 110 17%
l_discount WHERE RANGE 6% 39 6%
l_linestatus GROUP 6% 39 6%
l_quantity WHERE RANGE 6% 39 6%
l_returnflag WHERE 6% 39 6%
GROUP 6% 39 6%
l_shipmode WHERE RANGE 6% 39 6%
GROUP 6% 39 6%

Note: The "Total Time (s)" column indicates the cumulative time spent on queries involving each column.


Table: orders (11 reads and 1 write, Total Time: 500s)

Column Position Used % Total Time (s) % of Table Time
o_orderkey JOIN 83% 415 83%
WHERE RANGE 8% 40 8%
GROUP 8% 40 8%
o_custkey JOIN 58% 290 58%
o_orderdate WHERE RANGE 42% 210 42%
GROUP 17% 85 17%
o_comment WHERE RANGE 8% 40 8%
o_orderpriority GROUP 8% 40 8%
o_orderstatus WHERE 8% 40 8%
o_shippriority GROUP 8% 40 8%
o_totalprice GROUP 8% 40 8%

(Repeat the above format for each table, adjusting the data accordingly.)


Tables Joined with Timing

Join Relationship Occurrences Total Time (s) % of Total Time
lineitemorders 10 500 25%
└─ lineitem.l_orderkey = orders.o_orderkey
customerorders 7 350 17.5%
└─ customer.c_custkey = orders.o_custkey
lineitemsupplier 5 250 12.5%
└─ lineitem.l_suppkey = supplier.s_suppkey
lineitempart 3 150 7.5%
└─ lineitem.l_partkey = part.p_partkey
nationsupplier 6 80 4%
└─ nation.n_nationkey = supplier.s_nationkey
Other Joins 670 33.5%
Total 2,000 100%

Note: The "Total Time (s)" column represents the cumulative time spent on queries involving each join.


Failures

Query Error Count
I am a failing query; syntax error at position 2 near 'I' 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment