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-13' and l_shipdate > date '1995-03-13' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2691080.57..2691080.59 rows=10 width=20) (actual time=34201.190..34201.192 rows=10 loops=1) Buffers: shared hit=855269 read=511692 written=110 -> Sort (cost=2691080.57..2699084.49 rows=3201571 width=20) (actual time=34201.188..34201.188 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=855269 read=511692 written=110 -> HashAggregate (cost=2589880.06..2621895.77 rows=3201571 width=20) (actual time=34128.703..34179.536 rows=114134 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=855263 read=511692 written=110 -> Hash Join (cost=555329.20..2541856.49 rows=3201571 width=20) (actual time=9311.962..33876.046 rows=302270 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=855263 read=511692 written=110 -> Seq Scan on lineitem (cost=0.00..1831530.00 rows=32795090 width=12) (actual time=0.034..17942.982 rows=32414187 loops=1) Filter: (l_shipdate > '1995-03-13'::date) Rows Removed by Filter: 27629895 Buffers: shared hit=639571 read=435405 written=4 -> Hash (cost=536860.08..536860.08 rows=1477529 width=12) (actual time=9295.018..9295.018 rows=1460805 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79153kB Buffers: shared hit=215692 read=76287 written=106 -> Hash Join (cost=49816.18..536860.08 rows=1477529 width=12) (actual time=842.563..8684.214 rows=1460805 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=215692 read=76287 written=106 -> Seq Scan on orders (cost=0.00..444735.19 rows=7342247 width=16) (actual time=0.030..4712.851 rows=7284686 loops=1) Filter: (o_orderdate < '1995-03-13'::date) Rows Removed by Filter: 7730314 Buffers: shared hit=215689 read=39859 written=39 -> Hash (cost=46042.99..46042.99 rows=301855 width=4) (actual time=838.035..838.035 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=3 read=36428 written=67 -> Bitmap Heap Scan on customer (cost=6991.80..46042.99 rows=301855 width=4) (actual time=105.477..727.720 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=3 read=36428 written=67 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6916.34 rows=301855 width=0) (actual time=93.616..93.616 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 written=2 Planning time: 3.894 ms Execution time: 34231.466 ms (38 rows) COMMIT; COMMIT