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 ('REG AIR', 'TRUCK') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1996-01-01' and l_receiptdate < date '1996-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=981778.97..981778.97 rows=1 width=27) (actual time=46681.906..46681.908 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1164328 read=197637 dirtied=58 written=7817 -> HashAggregate (cost=981778.95..981778.96 rows=1 width=27) (actual time=46681.783..46681.784 rows=2 loops=1) Buffers: shared hit=1164323 read=197637 dirtied=58 written=7817 -> Hash Join (cost=591949.28..976672.78 rows=291781 width=27) (actual time=21509.963..46065.822 rows=313717 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1164323 read=197637 dirtied=58 written=7817 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..375605.34 rows=291781 width=15) (actual time=0.398..23007.534 rows=313717 loops=1) Filter: ((l_shipmode = ANY ('{"REG AIR",TRUCK}'::bpchar[])) AND (l_receiptdate >= '1996-01-01'::date) AND (l_receiptdate < '1997-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6883539 Buffers: shared hit=910674 read=197508 dirtied=58 written=7817 -> Hash (cost=404074.68..404074.68 rows=15029968 width=20) (actual time=21497.817..21497.817 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=253646 read=129 -> Seq Scan on orders (cost=0.00..404074.68 rows=15029968 width=20) (actual time=0.031..8148.705 rows=15015000 loops=1) Buffers: shared hit=253646 read=129 Total runtime: 46874.866 ms (19 rows) COMMIT; COMMIT