load 'auto_explain'; LOAD set auto_explain.log_min_duration to 0; SET set auto_explain.log_analyze to on; SET set auto_explain.log_wal to on; SET set auto_explain.log_timing to on; SET set auto_explain.log_level to notice; SET BEGIN; BEGIN select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date '1995-05-01' and o_orderdate < cast(date '1995-05-01' + interval '3 month' as date) and exists ( select * from lineitem where l_orderkey = o_orderkey and l_commitdate < l_receiptdate ) group by o_orderpriority order by o_orderpriority; NOTICE: duration: 1301.970 ms plan: Query Text: select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date '1995-05-01' and o_orderdate < cast(date '1995-05-01' + interval '3 month' as date) and exists ( select * from lineitem where l_orderkey = o_orderkey and l_commitdate < l_receiptdate ) group by o_orderpriority order by o_orderpriority; Finalize GroupAggregate (cost=516265.06..516313.41 rows=5 width=24) (actual time=1261.188..1301.955 rows=5 loops=1) Group Key: orders.o_orderpriority -> Gather Merge (cost=516265.06..516313.31 rows=10 width=24) (actual time=1250.367..1301.941 rows=15 loops=1) Workers Planned: 2 Workers Launched: 2 -> Partial GroupAggregate (cost=515265.04..515312.14 rows=5 width=24) (actual time=1247.476..1288.835 rows=5 loops=3) Group Key: orders.o_orderpriority -> Sort (cost=515265.04..515280.72 rows=6273 width=16) (actual time=1236.834..1265.497 rows=175364 loops=3) Sort Key: orders.o_orderpriority Sort Method: external merge Disk: 4512kB Worker 0: Sort Method: external merge Disk: 4448kB Worker 1: Sort Method: external merge Disk: 4472kB -> Nested Loop Semi Join (cost=0.56..514869.37 rows=6273 width=16) (actual time=0.057..1178.269 rows=175364 loops=3) -> Parallel Seq Scan on orders (cost=0.00..363241.27 rows=232867 width=24) (actual time=0.018..654.815 rows=191211 loops=3) Filter: ((o_orderdate >= '1995-05-01'::date) AND (o_orderdate < '1995-08-01'::date)) Rows Removed by Filter: 4808789 -> Index Only Scan using lineitem_l_orderkey_l_suppkey_idx on lineitem (cost=0.56..4.66 rows=49 width=8) (actual time=0.002..0.002 rows=1 loops=573632) Index Cond: (l_orderkey = orders.o_orderkey) Heap Fetches: 2220 o_orderpriority | order_count -----------------+------------- 1-URGENT | 105661 2-HIGH | 104819 3-MEDIUM | 105542 4-NOT SPECIFIED | 104835 5-LOW | 105236 (5 rows) COMMIT; COMMIT