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-28' and l_shipdate > date '1995-03-28' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2766441.64..2766441.66 rows=10 width=20) (actual time=122983.548..122983.553 rows=10 loops=1) Buffers: shared hit=1162772 read=206836 written=208 -> Sort (cost=2766441.64..2774350.41 rows=3163507 width=20) (actual time=122983.543..122983.545 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=1162772 read=206836 written=208 -> HashAggregate (cost=2666444.32..2698079.39 rows=3163507 width=20) (actual time=122871.428..122957.697 rows=113648 loops=1) Buffers: shared hit=1162766 read=206836 written=208 -> Hash Join (cost=631138.16..2618991.71 rows=3163507 width=20) (actual time=37973.521..122207.177 rows=300125 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1162766 read=206836 written=208 -> Seq Scan on lineitem (cost=0.00..1835173.36 rows=32278699 width=12) (actual time=0.061..60734.350 rows=32039730 loops=1) Filter: (l_shipdate > '1995-03-28'::date) Rows Removed by Filter: 28005142 Buffers: shared hit=888491 read=188629 written=208 -> Hash (cost=612559.96..612559.96 rows=1486256 width=12) (actual time=37970.366..37970.366 rows=1475493 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63401kB Buffers: shared hit=274275 read=18207 -> Hash Join (cost=49700.16..612559.96 rows=1486256 width=12) (actual time=2340.647..36999.864 rows=1475493 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=274275 read=18207 -> Seq Scan on orders (cost=0.00..445615.79 rows=7445924 width=16) (actual time=0.019..13735.394 rows=7378043 loops=1) Filter: (o_orderdate < '1995-03-28'::date) Rows Removed by Filter: 7636957 Buffers: shared hit=245153 read=10901 -> Hash (cost=45957.53..45957.53 rows=299410 width=4) (actual time=2340.344..2340.344 rows=300036 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10549kB Buffers: shared hit=29122 read=7306 -> Bitmap Heap Scan on customer (cost=6936.91..45957.53 rows=299410 width=4) (actual time=235.254..2166.382 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=29122 read=7306 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6862.06 rows=299410 width=0) (actual time=214.044..214.044 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=13 read=1140 Total runtime: 123024.325 ms (35 rows) COMMIT; COMMIT