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 '1993-02-01' and o_orderdate < cast(date '1993-02-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: 4131.634 ms plan: Query Text: select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date '1993-02-01' and o_orderdate < cast(date '1993-02-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=521173.88..521223.76 rows=5 width=24) (actual time=4051.364..4131.593 rows=5 loops=1) Group Key: orders.o_orderpriority -> Gather Merge (cost=521173.88..521223.66 rows=10 width=24) (actual time=3996.437..4131.528 rows=15 loops=1) Workers Planned: 2 Workers Launched: 2 -> Partial GroupAggregate (cost=520173.86..520222.48 rows=5 width=24) (actual time=3965.115..4059.075 rows=5 loops=3) Group Key: orders.o_orderpriority -> Sort (cost=520173.86..520190.05 rows=6476 width=16) (actual time=3942.225..4006.427 rows=169791 loops=3) Sort Key: orders.o_orderpriority Sort Method: external merge Disk: 4376kB Worker 0: Sort Method: external merge Disk: 4496kB Worker 1: Sort Method: external merge Disk: 4136kB -> Nested Loop Semi Join (cost=0.56..519763.90 rows=6476 width=16) (actual time=0.147..3761.983 rows=169791 loops=3) -> Parallel Seq Scan on orders (cost=0.00..363241.27 rows=240400 width=24) (actual time=0.056..2087.340 rows=185078 loops=3) Filter: ((o_orderdate >= '1993-02-01'::date) AND (o_orderdate < '1993-05-01'::date)) Rows Removed by Filter: 4814922 -> Index Only Scan using lineitem_l_orderkey_l_suppkey_idx on lineitem (cost=0.56..4.65 rows=49 width=8) (actual time=0.008..0.008 rows=1 loops=555233) Index Cond: (l_orderkey = orders.o_orderkey) Heap Fetches: 2195 o_orderpriority | order_count -----------------+------------- 1-URGENT | 102145 2-HIGH | 101788 3-MEDIUM | 101772 4-NOT SPECIFIED | 102044 5-LOW | 101624 (5 rows) COMMIT; COMMIT