explain.depesz.com

PostgreSQL's explain analyze made readable

Result: wOpS

Settings
# exclusive inclusive rows x rows loops node
1. 4,122.021 7,942.225 ↓ 1.4 1,368,523 1

Sort (cost=430,166.70..432,666.70 rows=1,000,000 width=70) (actual time=7,558.814..7,942.225 rows=1,368,523 loops=1)

  • Sort Key: c.customer_id, (((COALESCE(sale.quantity, 0))::numeric * COALESCE(sale.price, 0.0))) DESC
  • Sort Method: external merge Disk: 77096kB
2. 1,191.091 3,820.204 ↓ 1.4 1,368,523 1

Merge Right Join (cost=167,017.52..248,475.86 rows=1,000,000 width=70) (actual time=1,177.789..3,820.204 rows=1,368,523 loops=1)

  • Merge Cond: ((sale.customer_id = c.customer_id) AND (sale.product_id = p.product_id))
3. 1,016.769 1,016.769 ↑ 1.0 1,000,000 1

Index Scan using sale_index on sale (cost=0.42..51,459.77 rows=1,000,000 width=17) (actual time=0.007..1,016.769 rows=1,000,000 loops=1)

4. 136.412 1,612.344 ↓ 1.4 1,368,523 1

Materialize (cost=167,017.09..172,017.09 rows=1,000,000 width=34) (actual time=1,177.763..1,612.344 rows=1,368,523 loops=1)

5. 1,291.799 1,475.932 ↑ 1.0 1,000,000 1

Sort (cost=167,017.09..169,517.09 rows=1,000,000 width=34) (actual time=1,177.757..1,475.932 rows=1,000,000 loops=1)

  • Sort Key: c.customer_id, p.product_id
  • Sort Method: external merge Disk: 45344kB
6. 132.374 184.133 ↑ 1.0 1,000,000 1

Nested Loop (cost=0.00..12,668.25 rows=1,000,000 width=34) (actual time=0.033..184.133 rows=1,000,000 loops=1)

7. 1.759 1.759 ↑ 1.0 10,000 1

Seq Scan on customer c (cost=0.00..166.00 rows=10,000 width=18) (actual time=0.016..1.759 rows=10,000 loops=1)

8. 49.980 50.000 ↑ 1.0 100 10,000

Materialize (cost=0.00..2.50 rows=100 width=16) (actual time=0.000..0.005 rows=100 loops=10,000)

9. 0.020 0.020 ↑ 1.0 100 1

Seq Scan on product p (cost=0.00..2.00 rows=100 width=16) (actual time=0.014..0.020 rows=100 loops=1)