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 '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=988936.05..988936.06 rows=1 width=27) (actual time=28133.011..28133.012 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=702729 read=658972 dirtied=549 written=12916 -> HashAggregate (cost=988936.03..988936.04 rows=1 width=27) (actual time=28132.952..28132.953 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=702724 read=658972 dirtied=549 written=12916 -> Hash Join (cost=596675.51..983825.09 rows=292054 width=27) (actual time=12836.884..27784.242 rows=312722 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=702724 read=658972 dirtied=549 written=12916 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..378023.32 rows=292054 width=15) (actual time=0.110..14546.401 rows=312722 loops=1) Filter: ((l_shipmode = ANY ('{TRUCK,"REG AIR"}'::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: 6883840 Buffers: shared hit=532525 read=573367 dirtied=549 written=12740 -> Hash (cost=407300.59..407300.59 rows=15149959 width=20) (actual time=12597.192..12597.192 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=170196 read=85605 written=176 -> Seq Scan on orders (cost=0.00..407300.59 rows=15149959 width=20) (actual time=0.024..6596.412 rows=15015000 loops=1) Buffers: shared hit=170196 read=85605 written=176 Planning time: 3.528 ms Execution time: 28161.941 ms (21 rows) COMMIT; COMMIT