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-04' and l_shipdate > date '1995-03-04' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2746311.60..2746311.62 rows=10 width=20) (actual time=103103.974..103103.977 rows=10 loops=1) Buffers: shared hit=1023383 read=335685 dirtied=1054 written=1549 -> Sort (cost=2746311.60..2754205.25 rows=3157460 width=20) (actual time=103103.969..103103.971 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=1023383 read=335685 dirtied=1054 written=1549 -> HashAggregate (cost=2646505.42..2678080.02 rows=3157460 width=20) (actual time=102978.103..103073.070 rows=113600 loops=1) Buffers: shared hit=1023377 read=335685 dirtied=1054 written=1549 -> Hash Join (cost=624015.56..2599143.52 rows=3157460 width=20) (actual time=33423.305..102357.937 rows=299163 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1023377 read=335685 dirtied=1054 written=1549 -> Seq Scan on lineitem (cost=0.00..1820676.68 rows=32767115 width=12) (actual time=0.049..45251.201 rows=32640760 loops=1) Filter: (l_shipdate > '1995-03-04'::date) Rows Removed by Filter: 27404619 Buffers: shared hit=763348 read=305260 dirtied=1054 written=1549 -> Hash (cost=605893.80..605893.80 rows=1449741 width=12) (actual time=33421.188..33421.188 rows=1446111 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62138kB Buffers: shared hit=260029 read=30425 -> Hash Join (cost=49746.29..605893.80 rows=1449741 width=12) (actual time=1778.004..32405.363 rows=1446111 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=260029 read=30425 -> Seq Scan on orders (cost=0.00..442089.90 rows=7240742 width=16) (actual time=0.024..11232.652 rows=7227948 loops=1) Filter: (o_orderdate < '1995-03-04'::date) Rows Removed by Filter: 7787052 Buffers: shared hit=231852 read=22176 -> Hash (cost=45992.16..45992.16 rows=300330 width=4) (actual time=1777.730..1777.730 rows=299496 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10530kB Buffers: shared hit=28177 read=8249 -> Bitmap Heap Scan on customer (cost=6960.04..45992.16 rows=300330 width=4) (actual time=223.661..1577.472 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared hit=28177 read=8249 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6884.96 rows=300330 width=0) (actual time=209.953..209.953 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1151 Total runtime: 103141.756 ms (35 rows) COMMIT; COMMIT