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 ('MAIL', '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=991691.82..991691.82 rows=1 width=27) (actual time=22271.033..22271.033 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=734299 read=639291 dirtied=112 written=494 -> HashAggregate (cost=991691.80..991691.81 rows=1 width=27) (actual time=22270.977..22270.979 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=734294 read=639291 dirtied=112 written=494 -> Hash Join (cost=597855.79..986564.82 rows=292970 width=27) (actual time=10194.675..21978.567 rows=312426 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=734294 read=639291 dirtied=112 written=494 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..379554.15 rows=292970 width=15) (actual time=0.162..11402.249 rows=312426 loops=1) Filter: ((l_shipmode = ANY ('{MAIL,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: 6876970 Buffers: shared hit=527761 read=589514 dirtied=112 written=372 -> Hash (cost=408106.27..408106.27 rows=15179927 width=20) (actual time=10087.855..10087.855 rows=15000000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 892791kB Buffers: shared hit=206530 read=49777 written=122 -> Seq Scan on orders (cost=0.00..408106.27 rows=15179927 width=20) (actual time=0.019..4864.241 rows=15000000 loops=1) Buffers: shared hit=206530 read=49777 written=122 Planning time: 2.639 ms Execution time: 22287.511 ms (21 rows) COMMIT; COMMIT