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 ('FOB', 'MAIL') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1994-01-01' and l_receiptdate < date '1994-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=987933.25..987933.26 rows=1 width=27) (actual time=21509.802..21509.803 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=874144 read=483473 dirtied=56 written=646 -> HashAggregate (cost=987933.23..987933.24 rows=1 width=27) (actual time=21509.734..21509.735 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=874139 read=483473 dirtied=56 written=646 -> Hash Join (cost=596085.37..982834.70 rows=291345 width=27) (actual time=10354.140..21232.937 rows=310747 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=874139 read=483473 dirtied=56 written=646 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..377645.23 rows=291345 width=15) (actual time=0.205..10535.927 rows=310747 loops=1) Filter: ((l_shipmode = ANY ('{FOB,MAIL}'::bpchar[])) AND (l_receiptdate >= '1994-01-01'::date) AND (l_receiptdate < '1995-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6878643 Buffers: shared hit=630317 read=471744 dirtied=56 written=646 -> Hash (cost=406897.75..406897.75 rows=15134975 width=20) (actual time=9464.500..9464.500 rows=15000000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 892791kB Buffers: shared hit=243819 read=11729 -> Seq Scan on orders (cost=0.00..406897.75 rows=15134975 width=20) (actual time=0.021..4231.146 rows=15000000 loops=1) Buffers: shared hit=243819 read=11729 Planning time: 2.752 ms Execution time: 21534.507 ms (21 rows) COMMIT; COMMIT