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-02' and l_shipdate > date '1995-03-02' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2698088.62..2698088.64 rows=10 width=20) (actual time=34251.826..34251.831 rows=10 loops=1) Buffers: shared hit=716705 read=654221 dirtied=168 written=401 -> Sort (cost=2698088.62..2706067.63 rows=3191605 width=20) (actual time=34251.823..34251.825 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=716705 read=654221 dirtied=168 written=401 -> HashAggregate (cost=2597203.13..2629119.18 rows=3191605 width=20) (actual time=34182.684..34231.238 rows=113557 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=716699 read=654221 dirtied=168 written=401 -> Hash Join (cost=556020.13..2549329.06 rows=3191605 width=20) (actual time=9229.918..33927.015 rows=299162 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=716699 read=654221 dirtied=168 written=401 -> Seq Scan on lineitem (cost=0.00..1837002.56 rows=33170751 width=12) (actual time=0.062..19245.354 rows=32690141 loops=1) Filter: (l_shipdate > '1995-03-02'::date) Rows Removed by Filter: 27354853 Buffers: shared hit=542785 read=535403 written=5 -> Hash (cost=537762.95..537762.95 rows=1460574 width=12) (actual time=9217.699..9217.699 rows=1443631 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78416kB Buffers: shared hit=173914 read=118818 dirtied=168 written=396 -> Hash Join (cost=49740.43..537762.95 rows=1460574 width=12) (actual time=827.016..8665.274 rows=1443631 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=173914 read=118818 dirtied=168 written=396 -> Seq Scan on orders (cost=0.00..446056.09 rows=7296184 width=16) (actual time=0.026..5351.691 rows=7215455 loops=1) Filter: (o_orderdate < '1995-03-02'::date) Rows Removed by Filter: 7799545 Buffers: shared hit=173912 read=82395 dirtied=168 written=356 -> Hash (cost=45987.00..45987.00 rows=300275 width=4) (actual time=823.984..823.984 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=2 read=36423 written=40 -> Bitmap Heap Scan on customer (cost=6955.56..45987.00 rows=300275 width=4) (actual time=78.877..726.494 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36423 written=40 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6880.49 rows=300275 width=0) (actual time=69.618..69.618 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 written=1 Planning time: 4.316 ms Execution time: 34280.354 ms (38 rows) COMMIT; COMMIT