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-17' and l_shipdate > date '1995-03-17' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2696782.39..2696782.42 rows=10 width=20) (actual time=38625.014..38625.019 rows=10 loops=1) Buffers: shared hit=935221 read=436279 written=817 -> Sort (cost=2696782.39..2704713.62 rows=3172491 width=20) (actual time=38625.010..38625.011 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=935221 read=436279 written=817 -> HashAggregate (cost=2596501.09..2628226.00 rows=3172491 width=20) (actual time=38543.058..38603.444 rows=113816 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=935215 read=436279 written=817 -> Hash Join (cost=556473.66..2548913.73 rows=3172491 width=20) (actual time=9708.294..38247.718 rows=300150 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=935215 read=436279 written=817 -> Seq Scan on lineitem (cost=0.00..1837974.60 rows=32730814 width=12) (actual time=0.066..21098.096 rows=32282221 loops=1) Filter: (l_shipdate > '1995-03-17'::date) Rows Removed by Filter: 27702631 Buffers: shared hit=719385 read=359375 -> Hash (cost=538081.90..538081.90 rows=1471341 width=12) (actual time=9688.878..9688.878 rows=1460304 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79132kB Buffers: shared hit=215830 read=76904 written=817 -> Hash Join (cost=49728.90..538081.90 rows=1471341 width=12) (actual time=561.908..9047.274 rows=1460304 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=215830 read=76904 written=817 -> Seq Scan on orders (cost=0.00..446056.09 rows=7355601 width=16) (actual time=0.024..5282.858 rows=7302414 loops=1) Filter: (o_orderdate < '1995-03-17'::date) Rows Removed by Filter: 7697586 Buffers: shared hit=181606 read=74701 written=671 -> Hash (cost=45978.34..45978.34 rows=300045 width=4) (actual time=557.670..557.670 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=34224 read=2203 written=146 -> Bitmap Heap Scan on customer (cost=6949.78..45978.34 rows=300045 width=4) (actual time=80.519..450.092 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=34224 read=2203 written=146 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6874.76 rows=300045 width=0) (actual time=70.615..70.615 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 written=57 Planning time: 3.724 ms Execution time: 38652.115 ms (38 rows) COMMIT; COMMIT