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=142302.988..142302.993 rows=10 loops=1) Buffers: shared hit=738704 read=630904 written=1 -> Sort (cost=2766441.64..2774350.41 rows=3163507 width=20) (actual time=142302.982..142302.983 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=738704 read=630904 written=1 -> HashAggregate (cost=2666444.32..2698079.39 rows=3163507 width=20) (actual time=142205.236..142280.307 rows=113648 loops=1) Buffers: shared hit=738698 read=630904 written=1 -> Hash Join (cost=631138.16..2618991.71 rows=3163507 width=20) (actual time=40884.504..141464.810 rows=300125 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=738698 read=630904 written=1 -> Seq Scan on lineitem (cost=0.00..1835173.36 rows=32278699 width=12) (actual time=0.072..76502.475 rows=32039730 loops=1) Filter: (l_shipdate > '1995-03-28'::date) Rows Removed by Filter: 28005142 Buffers: shared hit=503066 read=574054 written=1 -> Hash (cost=612559.96..612559.96 rows=1486256 width=12) (actual time=40882.541..40882.541 rows=1475493 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63401kB Buffers: shared hit=235632 read=56850 -> Hash Join (cost=49700.16..612559.96 rows=1486256 width=12) (actual time=4308.850..39884.790 rows=1475493 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=235632 read=56850 -> Seq Scan on orders (cost=0.00..445615.79 rows=7445924 width=16) (actual time=0.019..14599.912 rows=7378043 loops=1) Filter: (o_orderdate < '1995-03-28'::date) Rows Removed by Filter: 7636957 Buffers: shared hit=235629 read=20425 -> Hash (cost=45957.53..45957.53 rows=299410 width=4) (actual time=4308.495..4308.495 rows=300036 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10549kB Buffers: shared hit=3 read=36425 -> Bitmap Heap Scan on customer (cost=6936.91..45957.53 rows=299410 width=4) (actual time=238.877..4114.752 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=3 read=36425 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6862.06 rows=299410 width=0) (actual time=219.789..219.789 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1153 Total runtime: 142342.454 ms (35 rows) COMMIT; COMMIT