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 = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-08' and l_shipdate > date '1995-03-08' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2759041.82..2759041.84 rows=10 width=20) (actual time=97292.366..97292.373 rows=10 loops=1) Buffers: shared hit=1067978 read=297673 dirtied=254 written=101 -> Sort (cost=2759041.82..2766947.55 rows=3162291 width=20) (actual time=97292.362..97292.365 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=1067978 read=297673 dirtied=254 written=101 -> HashAggregate (cost=2659082.94..2690705.85 rows=3162291 width=20) (actual time=97137.190..97254.936 rows=113961 loops=1) Buffers: shared hit=1067972 read=297673 dirtied=254 written=101 -> Hash Join (cost=627183.65..2611648.57 rows=3162291 width=20) (actual time=31036.272..96545.474 rows=301633 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1067972 read=297673 dirtied=254 written=101 -> Seq Scan on lineitem (cost=0.00..1829723.76 rows=32831533 width=12) (actual time=0.052..40792.431 rows=32506958 loops=1) Filter: (l_shipdate > '1995-03-08'::date) Rows Removed by Filter: 27477561 Buffers: shared hit=788105 read=285813 written=9 -> Hash (cost=608979.42..608979.42 rows=1456338 width=12) (actual time=31033.818..31033.818 rows=1452939 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62431kB Buffers: shared hit=279867 read=11860 dirtied=254 written=92 -> Hash Join (cost=49684.86..608979.42 rows=1456338 width=12) (actual time=1081.451..30004.506 rows=1452939 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=279867 read=11860 dirtied=254 written=92 -> Seq Scan on orders (cost=0.00..444294.89 rows=7304458 width=16) (actual time=0.031..10121.049 rows=7246287 loops=1) Filter: (o_orderdate < '1995-03-08'::date) Rows Removed by Filter: 7753713 Buffers: shared hit=253341 read=1954 dirtied=254 written=92 -> Hash (cost=45946.55..45946.55 rows=299065 width=4) (actual time=1081.136..1081.136 rows=300276 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10557kB Buffers: shared hit=26526 read=9906 -> Bitmap Heap Scan on customer (cost=6930.23..45946.55 rows=299065 width=4) (actual time=164.367..880.864 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared hit=26526 read=9906 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6855.47 rows=299065 width=0) (actual time=145.861..145.861 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1155 Total runtime: 97529.441 ms (35 rows) COMMIT; COMMIT