BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = 'HOUSEHOLD' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-17' and l_shipdate > date '1995-03-17' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2742172.75..2742172.77 rows=10 width=20) (actual time=68816.468..68816.472 rows=10 loops=1) Buffers: shared hit=612746 read=745009 dirtied=252 written=123 -> Sort (cost=2742172.75..2750008.76 rows=3134406 width=20) (actual time=68816.465..68816.468 rows=10 loops=1) Sort Key: (sum((lineitem.l_extendedprice * (1::double precision - lineitem.l_discount)))), orders.o_orderdate Sort Method: top-N heapsort Memory: 25kB Buffers: shared hit=612746 read=745009 dirtied=252 written=123 -> HashAggregate (cost=2643095.30..2674439.36 rows=3134406 width=20) (actual time=68737.228..68796.578 rows=113267 loops=1) Buffers: shared hit=612740 read=745009 dirtied=252 written=123 -> Hash Join (cost=624558.08..2596079.21 rows=3134406 width=20) (actual time=26368.902..68388.149 rows=299117 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=612740 read=745009 dirtied=252 written=123 -> Seq Scan on lineitem (cost=0.00..1818873.36 rows=32347655 width=12) (actual time=1.037..21297.659 rows=32315744 loops=1) Filter: (l_shipdate > '1995-03-17'::date) Rows Removed by Filter: 27729859 Buffers: shared hit=529474 read=538072 -> Hash (cost=606353.51..606353.51 rows=1456366 width=12) (actual time=26366.136..26366.136 rows=1458134 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62655kB Buffers: shared hit=83266 read=206937 dirtied=252 written=123 -> Hash Join (cost=49678.57..606353.51 rows=1456366 width=12) (actual time=477.399..25206.903 rows=1458134 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=83266 read=206937 dirtied=252 written=123 -> Seq Scan on orders (cost=0.00..441649.60 rows=7306304 width=16) (actual time=0.018..6324.491 rows=7309579 loops=1) Filter: (o_orderdate < '1995-03-17'::date) Rows Removed by Filter: 7705421 Buffers: shared hit=47991 read=205784 dirtied=252 written=123 -> Hash (cost=45941.13..45941.13 rows=298995 width=4) (actual time=477.204..477.204 rows=299751 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10539kB Buffers: shared hit=35275 read=1153 -> Bitmap Heap Scan on customer (cost=6925.69..45941.13 rows=298995 width=4) (actual time=75.861..391.390 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared hit=35275 read=1153 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6850.94 rows=298995 width=0) (actual time=66.321..66.321 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1153 Total runtime: 68858.580 ms (35 rows) COMMIT; COMMIT