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-23' and l_shipdate > date '1995-03-23' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2697249.65..2697249.67 rows=10 width=20) (actual time=32983.472..32983.475 rows=10 loops=1) Buffers: shared hit=805471 read=565893 written=6949 -> Sort (cost=2697249.65..2705209.59 rows=3183977 width=20) (actual time=32983.468..32983.469 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=805471 read=565893 written=6949 -> HashAggregate (cost=2596605.28..2628445.05 rows=3183977 width=20) (actual time=32913.638..32962.435 rows=113680 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=805465 read=565893 written=6949 -> Hash Join (cost=556875.53..2548845.62 rows=3183977 width=20) (actual time=9506.842..32671.024 rows=299913 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=805465 read=565893 written=6949 -> Seq Scan on lineitem (cost=0.00..1837740.15 rows=32637381 width=12) (actual time=0.032..17926.173 rows=32132362 loops=1) Filter: (l_shipdate > '1995-03-23'::date) Rows Removed by Filter: 27852490 Buffers: shared hit=663119 read=415505 -> Hash (cost=538364.34..538364.34 rows=1480895 width=12) (actual time=9492.464..9492.464 rows=1467767 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79453kB Buffers: shared hit=142346 read=150388 written=6949 -> Hash Join (cost=49724.64..538364.34 rows=1480895 width=12) (actual time=827.675..8932.818 rows=1467767 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=142346 read=150388 written=6949 -> Seq Scan on orders (cost=0.00..446056.09 rows=7406575 width=16) (actual time=0.024..5590.419 rows=7339881 loops=1) Filter: (o_orderdate < '1995-03-23'::date) Rows Removed by Filter: 7660119 Buffers: shared hit=142344 read=113963 written=4600 -> Hash (cost=45975.71..45975.71 rows=299915 width=4) (actual time=824.119..824.119 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=2 read=36425 written=2349 -> Bitmap Heap Scan on customer (cost=6948.77..45975.71 rows=299915 width=4) (actual time=77.694..727.485 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 written=2349 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6873.79 rows=299915 width=0) (actual time=68.741..68.741 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 written=89 Planning time: 4.099 ms Execution time: 33007.902 ms (38 rows) COMMIT; COMMIT