Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#22150] YSQL, QueryDiagnostics: EXPLAIN (ANALYZE, DIST) support for …
…queryDiagnostics Summary: - This diff adds functionality for `explain_analyze` and `explain_dist` params. - Note: This diff does not include code for supporting EXPLAIN(ANALYZE, DIST, DEBUG) - Explain.txt looks like:- ``` duration: 6.407 ms plan: Sort (cost=550.02..550.85 rows=333 width=116) (actual time=6.390..6.390 rows=0 loops=1) Sort Key: (sum(o.total_amount)) DESC, (count(DISTINCT o.order_id)) DESC Sort Method: quicksort Memory: 25kB -> GroupAggregate (cost=496.90..536.07 rows=333 width=116) (actual time=6.377..6.377 rows=0 loops=1) Group Key: c.customer_id, ((((c.first_name)::text || ' '::text) || (c.last_name)::text)) Filter: (count(DISTINCT o.order_id) > 0) -> Sort (cost=496.90..499.40 rows=1000 width=178) (actual time=6.374..6.374 rows=0 loops=1) Sort Key: c.customer_id, ((((c.first_name)::text || ' '::text) || (c.last_name)::text)) Sort Method: quicksort Memory: 25kB -> YB Batched Nested Loop Left Join (cost=117.50..447.07 rows=1000 width=178) (actual time=6.362..6.362 rows=0 loops=1) Join Filter: (oi.product_id = p.product_id) -> YB Batched Nested Loop Join (cost=117.50..328.19 rows=1000 width=268) (actual time=6.359..6.359 rows=0 loops=1) Join Filter: (o.customer_id = c.customer_id) -> Hash Right Join (cost=117.50..225.69 rows=1000 width=32) (actual time=6.354..6.355 rows=0 loops=1) Hash Cond: (oi.order_id = o.order_id) -> Seq Scan on order_items oi (cost=0.00..100.00 rows=1000 width=12) (never executed) -> Hash (cost=105.00..105.00 rows=1000 width=24) (actual time=6.348..6.348 rows=0 loops=1) Buckets: 1024 Batches: 1 Memory Usage: 8kB -> Seq Scan on orders o (cost=0.00..105.00 rows=1000 width=24) (actual time=6.345..6.345 rows=0 loops=1) Storage Filter: ((order_date >= '2023-04-01'::date) AND (order_date <= '2023-05-31'::date)) Storage Table Read Requests: 1 Storage Table Read Execution Time: 0.000 ms -> Index Scan using customers_pkey on customers c (cost=0.00..0.12 rows=1 width=240) (never executed) Index Cond: (customer_id = ANY (ARRAY[o.customer_id, $1, $2, ..., $1023])) Storage Filter: (registration_date >= '2023-01-01'::date) -> Index Scan using products_pkey on products p (cost=0.00..0.11 rows=1 width=122) (never executed) Index Cond: (product_id = ANY (ARRAY[oi.product_id, $1025, $1026, ..., $2047])) duration: 6.559 ms plan: Sort (cost=550.02..550.85 rows=333 width=116) (actual time=6.537..6.537 rows=0 loops=1) Sort Key: (sum(o.total_amount)) DESC, (count(DISTINCT o.order_id)) DESC Sort Method: quicksort Memory: 25kB -> GroupAggregate (cost=496.90..536.07 rows=333 width=116) (actual time=6.526..6.526 rows=0 loops=1) Group Key: c.customer_id, ((((c.first_name)::text || ' '::text) || (c.last_name)::text)) Filter: (count(DISTINCT o.order_id) > 0) -> Sort (cost=496.90..499.40 rows=1000 width=178) (actual time=6.523..6.523 rows=0 loops=1) Sort Key: c.customer_id, ((((c.first_name)::text || ' '::text) || (c.last_name)::text)) Sort Method: quicksort Memory: 25kB -> YB Batched Nested Loop Left Join (cost=117.50..447.07 rows=1000 width=178) (actual time=6.515..6.515 rows=0 loops=1) Join Filter: (oi.product_id = p.product_id) -> YB Batched Nested Loop Join (cost=117.50..328.19 rows=1000 width=268) (actual time=6.511..6.511 rows=0 loops=1) Join Filter: (o.customer_id = c.customer_id) -> Hash Right Join (cost=117.50..225.69 rows=1000 width=32) (actual time=6.506..6.506 rows=0 loops=1) Hash Cond: (oi.order_id = o.order_id) -> Seq Scan on order_items oi (cost=0.00..100.00 rows=1000 width=12) (never executed) -> Hash (cost=105.00..105.00 rows=1000 width=24) (actual time=6.497..6.497 rows=0 loops=1) Buckets: 1024 Batches: 1 Memory Usage: 8kB -> Seq Scan on orders o (cost=0.00..105.00 rows=1000 width=24) (actual time=6.494..6.494 rows=0 loops=1) Storage Filter: ((order_date >= '2023-04-01'::date) AND (order_date <= '2023-05-31'::date)) Storage Table Read Requests: 1 Storage Table Read Execution Time: 0.000 ms -> Index Scan using customers_pkey on customers c (cost=0.00..0.12 rows=1 width=240) (never executed) Index Cond: (customer_id = ANY (ARRAY[o.customer_id, $1, $2, ..., $1023])) Storage Filter: (registration_date >= '2023-01-01'::date) -> Index Scan using products_pkey on products p (cost=0.00..0.11 rows=1 width=122) (never executed) Index Cond: (product_id = ANY (ARRAY[oi.product_id, $1025, $1026, ..., $2047])) ``` Jira: DB-11078 Test Plan: ./yb_build.sh --java-test TestYbQueryDiagnostics#checkExplainData Testing with a large query that generates an EXPLAIN plan exceeding 16KB, causes output termination and loss of remaining data. This is expected and will be handled later [[ #23720 | #23720 ]] Reviewers: asaha, hbhanawat, telgersma Reviewed By: telgersma Subscribers: yql, ybase Differential Revision: https://phorge.dev.yugabyte.com/D35566
- Loading branch information