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', 'REG AIR') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1995-01-01' and l_receiptdate < date '1995-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=989167.93..989167.94 rows=1 width=27) (actual time=23880.863..23880.864 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=914664 read=454384 dirtied=1076 written=633 -> HashAggregate (cost=989167.91..989167.92 rows=1 width=27) (actual time=23880.798..23880.800 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=914659 read=454384 dirtied=1076 written=633 -> Hash Join (cost=596675.51..984038.68 rows=293099 width=27) (actual time=10643.380..23571.299 rows=312652 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=914659 read=454384 dirtied=1076 written=633 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..378204.26 rows=293099 width=15) (actual time=0.087..12415.691 rows=312652 loops=1) Filter: ((l_shipmode = ANY ('{TRUCK,"REG AIR"}'::bpchar[])) AND (l_receiptdate >= '1995-01-01'::date) AND (l_receiptdate < '1996-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6883910 Buffers: shared hit=693019 read=420220 dirtied=853 written=591 -> Hash (cost=407300.59..407300.59 rows=15149959 width=20) (actual time=10548.453..10548.453 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=221637 read=34164 dirtied=223 written=42 -> Seq Scan on orders (cost=0.00..407300.59 rows=15149959 width=20) (actual time=0.022..5106.478 rows=15015000 loops=1) Buffers: shared hit=221637 read=34164 dirtied=223 written=42 Planning time: 3.070 ms Execution time: 23892.227 ms (21 rows) COMMIT; COMMIT