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-13' and l_shipdate > date '1995-03-13' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2747433.62..2747433.64 rows=10 width=20) (actual time=82610.182..82610.187 rows=10 loops=1) Buffers: shared hit=662552 read=697829 dirtied=296 written=1 -> Sort (cost=2747433.62..2755286.22 rows=3141042 width=20) (actual time=82610.177..82610.179 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=662552 read=697829 dirtied=296 written=1 -> HashAggregate (cost=2648146.41..2679556.83 rows=3141042 width=20) (actual time=82512.696..82588.456 rows=113869 loops=1) Buffers: shared hit=662546 read=697829 dirtied=296 written=1 -> Hash Join (cost=625317.66..2601030.78 rows=3141042 width=20) (actual time=24952.831..81976.537 rows=300600 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=662546 read=697829 dirtied=296 written=1 -> Seq Scan on lineitem (cost=0.00..1822487.01 rows=32484182 width=12) (actual time=0.053..33005.605 rows=32415857 loops=1) Filter: (l_shipdate > '1995-03-13'::date) Rows Removed by Filter: 27629446 Buffers: shared hit=390021 read=679645 written=1 -> Hash (cost=607115.00..607115.00 rows=1456213 width=12) (actual time=24950.301..24950.301 rows=1456729 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62594kB Buffers: shared hit=272525 read=18184 dirtied=296 -> Hash Join (cost=49699.01..607115.00 rows=1456213 width=12) (actual time=860.423..23792.725 rows=1456729 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=272525 read=18184 dirtied=296 -> Seq Scan on orders (cost=0.00..442530.20 rows=7296266 width=16) (actual time=0.024..6649.650 rows=7284462 loops=1) Filter: (o_orderdate < '1995-03-13'::date) Rows Removed by Filter: 7730538 Buffers: shared hit=238376 read=15905 dirtied=296 -> Hash (cost=45956.82..45956.82 rows=299375 width=4) (actual time=860.099..860.099 rows=300036 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10549kB Buffers: shared hit=34149 read=2279 -> Bitmap Heap Scan on customer (cost=6936.64..45956.82 rows=299375 width=4) (actual time=161.753..709.240 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=34149 read=2279 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6861.79 rows=299375 width=0) (actual time=147.804..147.804 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1153 Total runtime: 82657.973 ms (35 rows) COMMIT; COMMIT