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 = 'FURNITURE' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-18' and l_shipdate > date '1995-03-18' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2759432.06..2759432.08 rows=10 width=20) (actual time=81643.487..81643.492 rows=10 loops=1) Buffers: shared hit=956296 read=410660 written=6 -> Sort (cost=2759432.06..2767268.64 rows=3134632 width=20) (actual time=81643.482..81643.486 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=956296 read=410660 written=6 -> HashAggregate (cost=2660347.47..2691693.79 rows=3134632 width=20) (actual time=81546.634..81621.715 rows=113254 loops=1) Buffers: shared hit=956290 read=410660 written=6 -> Hash Join (cost=628489.34..2613327.99 rows=3134632 width=20) (actual time=25875.974..81009.719 rows=298547 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=956290 read=410660 written=6 -> Seq Scan on lineitem (cost=0.00..1831527.38 rows=32523987 width=12) (actual time=0.068..32701.579 rows=32256117 loops=1) Filter: (l_shipdate > '1995-03-18'::date) Rows Removed by Filter: 27727805 Buffers: shared hit=702690 read=372286 -> Hash (cost=610255.65..610255.65 rows=1458695 width=12) (actual time=25872.419..25872.419 rows=1462150 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62827kB Buffers: shared hit=253600 read=38374 written=6 -> Hash Join (cost=49575.50..610255.65 rows=1458695 width=12) (actual time=1141.360..25038.377 rows=1462150 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=253600 read=38374 written=6 -> Seq Scan on orders (cost=0.00..444735.19 rows=7371492 width=16) (actual time=0.021..6901.989 rows=7308802 loops=1) Filter: (o_orderdate < '1995-03-18'::date) Rows Removed by Filter: 7691198 Buffers: shared hit=253598 read=1950 written=6 -> Hash (cost=45865.19..45865.19 rows=296825 width=4) (actual time=1141.044..1141.044 rows=299496 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10530kB Buffers: shared hit=2 read=36424 -> Bitmap Heap Scan on customer (cost=6876.87..45865.19 rows=296825 width=4) (actual time=119.436..988.147 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared hit=2 read=36424 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6802.67 rows=296825 width=0) (actual time=106.021..106.021 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1151 Total runtime: 81685.923 ms (35 rows) COMMIT; COMMIT