BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select l_shipmode, sum(case when o_orderpriority = '1-URGENT' or o_orderpriority = '2-HIGH' then 1 else 0 end) as high_line_count, sum(case when o_orderpriority <> '1-URGENT' and o_orderpriority <> '2-HIGH' then 1 else 0 end) as low_line_count from orders, lineitem where o_orderkey = l_orderkey and l_shipmode in ('AIR', 'SHIP') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1993-01-01' and l_receiptdate < date '1993-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=990438.33..990438.34 rows=1 width=27) (actual time=50892.698..50892.699 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1227544 read=150000 dirtied=178 written=6 -> HashAggregate (cost=990438.31..990438.32 rows=1 width=27) (actual time=50892.564..50892.565 rows=2 loops=1) Buffers: shared hit=1227539 read=150000 dirtied=178 written=6 -> Hash Join (cost=597265.22..985340.28 rows=291316 width=27) (actual time=21104.018..50242.950 rows=313314 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1227539 read=150000 dirtied=178 written=6 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..378971.44 rows=291316 width=15) (actual time=0.158..27881.422 rows=313314 loops=1) Filter: ((l_shipmode = ANY ('{AIR,SHIP}'::bpchar[])) AND (l_receiptdate >= '1993-01-01'::date) AND (l_receiptdate < '1994-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6883268 Buffers: shared hit=982593 read=138889 dirtied=148 written=6 -> Hash (cost=407703.43..407703.43 rows=15164943 width=20) (actual time=21090.157..21090.157 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=244943 read=11111 dirtied=30 -> Seq Scan on orders (cost=0.00..407703.43 rows=15164943 width=20) (actual time=0.027..11954.677 rows=15015000 loops=1) Buffers: shared hit=244943 read=11111 dirtied=30 Total runtime: 50983.804 ms (19 rows) COMMIT; COMMIT