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-13' and l_shipdate > date '1995-03-13' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2762506.73..2762506.76 rows=10 width=20) (actual time=136733.245..136733.251 rows=10 loops=1) Buffers: shared hit=914779 read=453502 dirtied=1056 written=434 -> Sort (cost=2762506.73..2770376.79 rows=3148023 width=20) (actual time=136733.241..136733.246 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=914779 read=453502 dirtied=1056 written=434 -> HashAggregate (cost=2662998.86..2694479.09 rows=3148023 width=20) (actual time=136632.882..136710.417 rows=113113 loops=1) Buffers: shared hit=914773 read=453502 dirtied=1056 written=434 -> Hash Join (cost=628699.10..2615778.51 rows=3148023 width=20) (actual time=38927.497..135676.108 rows=298462 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=914773 read=453502 dirtied=1056 written=434 -> Seq Scan on lineitem (cost=0.00..1833343.51 rows=32601512 width=12) (actual time=0.040..70649.123 rows=32414041 loops=1) Filter: (l_shipdate > '1995-03-13'::date) Rows Removed by Filter: 27630135 Buffers: shared hit=627438 read=448608 dirtied=804 written=421 -> Hash (cost=610412.97..610412.97 rows=1462890 width=12) (actual time=38923.374..38923.374 rows=1453166 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62441kB Buffers: shared hit=287335 read=4894 dirtied=252 written=13 -> Hash Join (cost=49676.60..610412.97 rows=1462890 width=12) (actual time=2012.998..37926.579 rows=1453166 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=287335 read=4894 dirtied=252 written=13 -> Seq Scan on orders (cost=0.00..445175.49 rows=7340508 width=16) (actual time=0.045..14860.532 rows=7284649 loops=1) Filter: (o_orderdate < '1995-03-13'::date) Rows Removed by Filter: 7730351 Buffers: shared hit=253049 read=2752 dirtied=252 written=10 -> Hash (cost=45939.91..45939.91 rows=298935 width=4) (actual time=2012.693..2012.693 rows=299751 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10539kB Buffers: shared hit=34286 read=2142 written=3 -> Bitmap Heap Scan on customer (cost=6925.23..45939.91 rows=298935 width=4) (actual time=243.433..1847.064 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared hit=34286 read=2142 written=3 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6850.49 rows=298935 width=0) (actual time=230.907..230.907 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1153 written=3 Total runtime: 136777.387 ms (35 rows) COMMIT; COMMIT