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 ('RAIL', 'FOB') 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=989412.00..989412.01 rows=1 width=27) (actual time=26573.049..26573.049 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=653230 read=713521 dirtied=498 written=19624 -> HashAggregate (cost=989411.98..989411.99 rows=1 width=27) (actual time=26572.984..26572.985 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=653225 read=713521 dirtied=498 written=19624 -> Hash Join (cost=596675.51..984287.90 rows=292805 width=27) (actual time=13423.625..26264.996 rows=312907 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=653225 read=713521 dirtied=498 written=19624 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..378462.66 rows=292805 width=15) (actual time=0.229..12350.749 rows=312907 loops=1) Filter: ((l_shipmode = ANY ('{RAIL,FOB}'::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: 6883655 Buffers: shared hit=485876 read=625066 dirtied=498 written=19317 -> Hash (cost=407300.59..407300.59 rows=15149959 width=20) (actual time=13149.780..13149.780 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=167346 read=88455 written=307 -> Seq Scan on orders (cost=0.00..407300.59 rows=15149959 width=20) (actual time=0.021..5747.440 rows=15015000 loops=1) Buffers: shared hit=167346 read=88455 written=307 Planning time: 2.975 ms Execution time: 26603.095 ms (21 rows) COMMIT; COMMIT