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-29' and l_shipdate > date '1995-03-29' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2774846.48..2774846.51 rows=10 width=20) (actual time=82570.864..82570.868 rows=10 loops=1) Buffers: shared hit=718677 read=654889 dirtied=507 written=6 -> Sort (cost=2774846.48..2782787.45 rows=3176387 width=20) (actual time=82570.860..82570.863 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=718677 read=654889 dirtied=507 written=6 -> HashAggregate (cost=2674442.03..2706205.90 rows=3176387 width=20) (actual time=82483.561..82551.704 rows=113063 loops=1) Buffers: shared hit=718671 read=654889 dirtied=507 written=6 -> Hash Join (cost=632907.34..2626796.23 rows=3176387 width=20) (actual time=26272.619..81627.084 rows=298078 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=718671 read=654889 dirtied=507 written=6 -> Seq Scan on lineitem (cost=0.00..1840637.49 rows=32396673 width=12) (actual time=0.072..32042.556 rows=32014732 loops=1) Filter: (l_shipdate > '1995-03-29'::date) Rows Removed by Filter: 28030301 Buffers: shared hit=450955 read=629364 written=6 -> Hash (cost=614266.34..614266.34 rows=1491280 width=12) (actual time=26270.391..26270.391 rows=1472947 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63291kB Buffers: shared hit=267716 read=25525 dirtied=507 -> Hash Join (cost=49701.30..614266.34 rows=1491280 width=12) (actual time=686.821..24993.150 rows=1472947 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=267716 read=25525 dirtied=507 -> Seq Scan on orders (cost=0.00..446936.69 rows=7470222 width=16) (actual time=0.022..7112.046 rows=7384275 loops=1) Filter: (o_orderdate < '1995-03-29'::date) Rows Removed by Filter: 7630725 Buffers: shared hit=232443 read=24370 dirtied=507 -> Hash (cost=45958.24..45958.24 rows=299445 width=4) (actual time=686.541..686.541 rows=299751 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10539kB Buffers: shared hit=35273 read=1155 -> Bitmap Heap Scan on customer (cost=6937.18..45958.24 rows=299445 width=4) (actual time=118.049..548.218 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared hit=35273 read=1155 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6862.32 rows=299445 width=0) (actual time=105.676..105.676 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1153 Total runtime: 82611.308 ms (35 rows) COMMIT; COMMIT