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 = 'FURNITURE' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-07' and l_shipdate > date '1995-03-07' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2684429.60..2684429.62 rows=10 width=20) (actual time=39660.766..39660.770 rows=10 loops=1) Buffers: shared hit=779004 read=586640 dirtied=1 written=100 -> Sort (cost=2684429.60..2692282.16 rows=3141023 width=20) (actual time=39660.761..39660.762 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=779004 read=586640 dirtied=1 written=100 -> HashAggregate (cost=2585142.99..2616553.22 rows=3141023 width=20) (actual time=39587.077..39639.374 rows=113540 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=778998 read=586640 dirtied=1 written=100 -> Hash Join (cost=553741.39..2538027.65 rows=3141023 width=20) (actual time=11892.713..39301.955 rows=298826 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=778998 read=586640 dirtied=1 written=100 -> Seq Scan on lineitem (cost=0.00..1829724.88 rows=32840308 width=12) (actual time=0.035..20293.409 rows=32564576 loops=1) Filter: (l_shipdate > '1995-03-07'::date) Rows Removed by Filter: 27480088 Buffers: shared hit=580947 read=492971 dirtied=1 written=4 -> Hash (cost=535664.42..535664.42 rows=1446157 width=12) (actual time=11873.626..11873.626 rows=1449930 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78686kB Buffers: shared hit=198051 read=93669 written=96 -> Hash Join (cost=49659.45..535664.42 rows=1446157 width=12) (actual time=718.148..11097.561 rows=1449930 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=198051 read=93669 written=96 -> Seq Scan on orders (cost=0.00..444294.89 rows=7266271 width=16) (actual time=0.029..6719.166 rows=7247062 loops=1) Filter: (o_orderdate < '1995-03-07'::date) Rows Removed by Filter: 7767938 Buffers: shared hit=164654 read=90641 written=90 -> Hash (cost=45927.76..45927.76 rows=298535 width=4) (actual time=713.844..713.844 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=33397 read=3028 written=6 -> Bitmap Heap Scan on customer (cost=6918.07..45927.76 rows=298535 width=4) (actual time=116.989..569.956 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=33397 read=3028 written=6 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6843.44 rows=298535 width=0) (actual time=104.320..104.320 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 written=5 Planning time: 5.252 ms Execution time: 39691.233 ms (38 rows) COMMIT; COMMIT