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-14' and l_shipdate > date '1995-03-14' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2775323.26..2775323.29 rows=10 width=20) (actual time=88561.246..88561.251 rows=10 loops=1) Buffers: shared hit=852734 read=522146 written=1432 -> Sort (cost=2775323.26..2783201.16 rows=3151159 width=20) (actual time=88561.243..88561.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=852734 read=522146 written=1432 -> HashAggregate (cost=2675716.26..2707227.85 rows=3151159 width=20) (actual time=88471.037..88540.513 rows=113400 loops=1) Buffers: shared hit=852728 read=522146 written=1432 -> Hash Join (cost=631469.03..2628448.88 rows=3151159 width=20) (actual time=30159.331..87763.759 rows=298729 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=852728 read=522146 written=1432 -> Seq Scan on lineitem (cost=0.00..1842441.81 rows=32807051 width=12) (actual time=0.081..33754.684 rows=32390406 loops=1) Filter: (l_shipdate > '1995-03-14'::date) Rows Removed by Filter: 27654387 Buffers: shared hit=631748 read=449634 -> Hash (cost=613189.42..613189.42 rows=1462369 width=12) (actual time=30156.231..30156.231 rows=1458469 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62669kB Buffers: shared hit=220980 read=72512 written=1432 -> Hash Join (cost=49575.50..613189.42 rows=1462369 width=12) (actual time=1286.264..28987.167 rows=1458469 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=220980 read=72512 written=1432 -> Seq Scan on orders (cost=0.00..447376.99 rows=7390054 width=16) (actual time=0.015..9741.337 rows=7290640 loops=1) Filter: (o_orderdate < '1995-03-14'::date) Rows Removed by Filter: 7724360 Buffers: shared hit=185710 read=71356 written=1270 -> Hash (cost=45865.19..45865.19 rows=296825 width=4) (actual time=1286.069..1286.069 rows=299496 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10530kB Buffers: shared hit=35270 read=1156 written=162 -> Bitmap Heap Scan on customer (cost=6876.87..45865.19 rows=296825 width=4) (actual time=181.829..1120.432 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared hit=35270 read=1156 written=162 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6802.67 rows=296825 width=0) (actual time=170.608..170.608 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1151 written=161 Total runtime: 88599.564 ms (35 rows) COMMIT; COMMIT