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-03' and l_shipdate > date '1995-03-03' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2776372.40..2776372.43 rows=10 width=20) (actual time=82752.338..82752.343 rows=10 loops=1) Buffers: shared hit=878049 read=496831 written=867 -> Sort (cost=2776372.40..2784293.92 rows=3168607 width=20) (actual time=82752.332..82752.336 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=878049 read=496831 written=867 -> HashAggregate (cost=2676213.87..2707899.94 rows=3168607 width=20) (actual time=82624.469..82718.719 rows=113568 loops=1) Buffers: shared hit=878043 read=496831 written=867 -> Hash Join (cost=630435.31..2628684.77 rows=3168607 width=20) (actual time=26104.285..82100.214 rows=299174 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=878043 read=496831 written=867 -> Seq Scan on lineitem (cost=0.00..1842448.62 rows=33097269 width=12) (actual time=0.046..31565.747 rows=32665332 loops=1) Filter: (l_shipdate > '1995-03-03'::date) Rows Removed by Filter: 27379461 Buffers: shared hit=586435 read=494947 written=867 -> Hash (cost=612215.66..612215.66 rows=1457572 width=12) (actual time=26102.253..26102.253 rows=1444755 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62080kB Buffers: shared hit=291608 read=1884 -> Hash Join (cost=49674.31..612215.66 rows=1457572 width=12) (actual time=967.975..24550.064 rows=1444755 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=291608 read=1884 -> Seq Scan on orders (cost=0.00..447376.99 rows=7315538 width=16) (actual time=0.014..6493.692 rows=7221794 loops=1) Filter: (o_orderdate < '1995-03-03'::date) Rows Removed by Filter: 7793206 Buffers: shared hit=256333 read=733 -> Hash (cost=45938.50..45938.50 rows=298865 width=4) (actual time=967.773..967.773 rows=299496 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10530kB Buffers: shared hit=35275 read=1151 -> Bitmap Heap Scan on customer (cost=6924.68..45938.50 rows=298865 width=4) (actual time=180.355..797.185 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared hit=35275 read=1151 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6849.97 rows=298865 width=0) (actual time=167.784..167.784 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1151 Total runtime: 82800.469 ms (35 rows) COMMIT; COMMIT