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 ('TRUCK', '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=989116.94..989116.94 rows=1 width=27) (actual time=26481.282..26481.283 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=725083 read=640316 dirtied=56 written=1468 -> HashAggregate (cost=989116.92..989116.93 rows=1 width=27) (actual time=26481.196..26481.197 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=725078 read=640316 dirtied=56 written=1468 -> Hash Join (cost=596675.51..984005.99 rows=292053 width=27) (actual time=12178.939..26178.704 rows=313180 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=725078 read=640316 dirtied=56 written=1468 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..378204.26 rows=292053 width=15) (actual time=0.172..13485.549 rows=313180 loops=1) Filter: ((l_shipmode = ANY ('{TRUCK,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: 6883382 Buffers: shared hit=573130 read=536460 dirtied=56 written=1307 -> Hash (cost=407300.59..407300.59 rows=15149959 width=20) (actual time=12060.385..12060.385 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=151945 read=103856 written=161 -> Seq Scan on orders (cost=0.00..407300.59 rows=15149959 width=20) (actual time=0.020..6018.364 rows=15015000 loops=1) Buffers: shared hit=151945 read=103856 written=161 Planning time: 3.353 ms Execution time: 26491.862 ms (21 rows) COMMIT; COMMIT