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 = 'AUTOMOBILE' 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=2677626.16..2677626.19 rows=10 width=20) (actual time=46299.849..46299.853 rows=10 loops=1) Buffers: shared hit=810556 read=551151 written=19 -> Sort (cost=2677626.16..2685500.26 rows=3149640 width=20) (actual time=46299.845..46299.846 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=810556 read=551151 written=19 -> HashAggregate (cost=2578067.17..2609563.57 rows=3149640 width=20) (actual time=46217.567..46278.236 rows=113881 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=810550 read=551151 written=19 -> Hash Join (cost=552782.28..2530822.57 rows=3149640 width=20) (actual time=13930.225..45870.904 rows=300600 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=810550 read=551151 written=19 -> Seq Scan on lineitem (cost=0.00..1824310.25 rows=32595637 width=12) (actual time=0.041..22800.692 rows=32416064 loops=1) Filter: (l_shipdate > '1995-03-13'::date) Rows Removed by Filter: 27630157 Buffers: shared hit=600161 read=470579 written=4 -> Hash (cost=534574.11..534574.11 rows=1456654 width=12) (actual time=13914.137..13914.137 rows=1456779 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78980kB Buffers: shared hit=210389 read=80572 written=15 -> Hash Join (cost=49728.90..534574.11 rows=1456654 width=12) (actual time=1123.055..13029.781 rows=1456779 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=210389 read=80572 written=15 -> Seq Scan on orders (cost=0.00..442970.50 rows=7282178 width=16) (actual time=0.031..8026.039 rows=7284445 loops=1) Filter: (o_orderdate < '1995-03-13'::date) Rows Removed by Filter: 7730555 Buffers: shared hit=210387 read=44147 written=15 -> Hash (cost=45978.34..45978.34 rows=300045 width=4) (actual time=1119.329..1119.329 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=2 read=36425 -> Bitmap Heap Scan on customer (cost=6949.78..45978.34 rows=300045 width=4) (actual time=109.316..971.920 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6874.76 rows=300045 width=0) (actual time=97.593..97.593 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 Planning time: 6.216 ms Execution time: 46328.668 ms (38 rows) COMMIT; COMMIT