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=2683231.37..2683231.39 rows=10 width=20) (actual time=31540.374..31540.378 rows=10 loops=1) Buffers: shared hit=822790 read=541449 dirtied=145 written=853 -> Sort (cost=2683231.37..2691159.75 rows=3171354 width=20) (actual time=31540.370..31540.372 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=822790 read=541449 dirtied=145 written=853 -> HashAggregate (cost=2582986.01..2614699.55 rows=3171354 width=20) (actual time=31474.038..31519.999 rows=113656 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=822784 read=541449 dirtied=145 written=853 -> Hash Join (cost=554509.04..2535415.70 rows=3171354 width=20) (actual time=8346.219..31231.078 rows=299845 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=822784 read=541449 dirtied=145 written=853 -> Seq Scan on lineitem (cost=0.00..1827919.74 rows=32339569 width=12) (actual time=0.069..17772.438 rows=32133288 loops=1) Filter: (l_shipdate > '1995-03-23'::date) Rows Removed by Filter: 27852399 Buffers: shared hit=632562 read=440294 -> Hash (cost=535999.96..535999.96 rows=1480726 width=12) (actual time=8335.486..8335.486 rows=1467783 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79453kB Buffers: shared hit=190222 read=101155 dirtied=145 written=853 -> Hash Join (cost=49723.50..535999.96 rows=1480726 width=12) (actual time=476.566..7831.158 rows=1467783 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=190222 read=101155 dirtied=145 written=853 -> Seq Scan on orders (cost=0.00..443694.47 rows=7406595 width=16) (actual time=0.022..4917.235 rows=7339744 loops=1) Filter: (o_orderdate < '1995-03-23'::date) Rows Removed by Filter: 7660256 Buffers: shared hit=154947 read=100003 dirtied=145 written=784 -> Hash (cost=45975.00..45975.00 rows=299880 width=4) (actual time=473.645..473.645 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=35275 read=1152 written=69 -> Bitmap Heap Scan on customer (cost=6948.50..45975.00 rows=299880 width=4) (actual time=72.962..389.732 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35275 read=1152 written=69 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6873.53 rows=299880 width=0) (actual time=64.092..64.092 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 written=69 Planning time: 3.808 ms Execution time: 31564.713 ms (38 rows) COMMIT; COMMIT