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 = 'HOUSEHOLD' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-30' and l_shipdate > date '1995-03-30' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2696338.54..2696338.56 rows=10 width=20) (actual time=38993.018..38993.022 rows=10 loops=1) Buffers: shared hit=796810 read=575445 written=100 -> Sort (cost=2696338.54..2704227.32 rows=3155513 width=20) (actual time=38993.014..38993.014 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=796810 read=575445 written=100 -> HashAggregate (cost=2596593.91..2628149.04 rows=3155513 width=20) (actual time=38899.297..38973.380 rows=113087 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=796804 read=575445 written=100 -> Hash Join (cost=557342.14..2549261.21 rows=3155513 width=20) (actual time=12460.056..38610.107 rows=298009 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=796804 read=575445 written=100 -> Seq Scan on lineitem (cost=0.00..1838829.90 rows=32409078 width=12) (actual time=0.039..18285.911 rows=31989646 loops=1) Filter: (l_shipdate > '1995-03-30'::date) Rows Removed by Filter: 28055651 Buffers: shared hit=613125 read=466137 -> Hash (cost=538848.96..538848.96 rows=1479454 width=12) (actual time=12444.337..12444.337 rows=1474208 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79729kB Buffers: shared hit=183679 read=109308 written=100 -> Hash Join (cost=49634.91..538848.96 rows=1479454 width=12) (actual time=1018.566..11585.600 rows=1474208 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=183679 read=109308 written=100 -> Seq Scan on orders (cost=0.00..446496.39 rows=7446167 width=16) (actual time=0.025..5935.212 rows=7390489 loops=1) Filter: (o_orderdate < '1995-03-30'::date) Rows Removed by Filter: 7624511 Buffers: shared hit=183677 read=72883 written=22 -> Hash (cost=45909.54..45909.54 rows=298030 width=4) (actual time=1014.542..1014.542 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=2 read=36425 written=78 -> Bitmap Heap Scan on customer (cost=6906.16..45909.54 rows=298030 width=4) (actual time=115.671..904.523 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 written=78 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6831.65 rows=298030 width=0) (actual time=103.266..103.266 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 Planning time: 6.989 ms Execution time: 39027.711 ms (38 rows) COMMIT; COMMIT