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 = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-22' and l_shipdate > date '1995-03-22' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2776610.82..2776610.85 rows=10 width=20) (actual time=95334.155..95334.160 rows=10 loops=1) Buffers: shared hit=982187 read=391383 written=62 -> Sort (cost=2776610.82..2784616.56 rows=3202296 width=20) (actual time=95334.150..95334.152 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=982187 read=391383 written=62 -> HashAggregate (cost=2675387.40..2707410.36 rows=3202296 width=20) (actual time=95243.831..95313.834 rows=114156 loops=1) Buffers: shared hit=982181 read=391383 written=62 -> Hash Join (cost=632633.77..2627352.96 rows=3202296 width=20) (actual time=29813.264..94419.969 rows=302102 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=982181 read=391383 written=62 -> Seq Scan on lineitem (cost=0.00..1840630.70 rows=32550806 width=12) (actual time=0.059..39346.399 rows=32189575 loops=1) Filter: (l_shipdate > '1995-03-22'::date) Rows Removed by Filter: 27855458 Buffers: shared hit=791474 read=288845 written=7 -> Hash (cost=613929.71..613929.71 rows=1496325 width=12) (actual time=29810.342..29810.342 rows=1472115 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63255kB Buffers: shared hit=190707 read=102538 written=55 -> Hash Join (cost=49823.51..613929.71 rows=1496325 width=12) (actual time=1975.214..28773.575 rows=1472115 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=190707 read=102538 written=55 -> Seq Scan on orders (cost=0.00..446936.69 rows=7433183 width=16) (actual time=0.030..8214.546 rows=7340960 loops=1) Filter: (o_orderdate < '1995-03-22'::date) Rows Removed by Filter: 7674040 Buffers: shared hit=190705 read=66108 written=55 -> Hash (cost=46049.07..46049.07 rows=301955 width=4) (actual time=1973.908..1973.908 rows=300276 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10557kB Buffers: shared hit=2 read=36430 -> Bitmap Heap Scan on customer (cost=6996.63..46049.07 rows=301955 width=4) (actual time=140.092..1391.280 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared hit=2 read=36430 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6921.14 rows=301955 width=0) (actual time=126.616..126.616 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1155 Total runtime: 95398.909 ms (35 rows) COMMIT; COMMIT