explain.depesz.com

PostgreSQL's explain analyze made readable

Result: dafD

Settings
# exclusive inclusive rows x rows loops node
1. 3,914.539 8,380.429 ↓ 1.4 1,368,523 1

Sort (cost=517,730.40..520,230.40 rows=1,000,000 width=70) (actual time=7,967.970..8,380.429 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. 927.347 4,465.890 ↓ 1.4 1,368,523 1

Merge Left Join (cost=303,543.54..336,039.56 rows=1,000,000 width=70) (actual time=2,645.306..4,465.890 rows=1,368,523 loops=1)

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

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

  • Sort Key: c.customer_id, p.product_id
  • Sort Method: external merge Disk: 45344kB
4. 139.650 191.452 ↑ 1.0 1,000,000 1

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

5. 1.802 1.802 ↑ 1.0 10,000 1

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

6. 49.964 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)

7. 0.036 0.036 ↑ 1.0 100 1

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

8. 95.853 2,093.048 ↓ 1.0 1,000,000 1

Materialize (cost=136,525.69..141,525.32 rows=999,926 width=17) (actual time=1,465.245..2,093.048 rows=1,000,000 loops=1)

9. 1,814.874 1,997.195 ↓ 1.0 1,000,000 1

Sort (cost=136,525.69..139,025.51 rows=999,926 width=17) (actual time=1,465.237..1,997.195 rows=1,000,000 loops=1)

  • Sort Key: sale.customer_id, sale.product_id
  • Sort Method: external merge Disk: 29360kB
10. 182.321 182.321 ↓ 1.0 1,000,000 1

Seq Scan on sale (cost=0.00..16,369.26 rows=999,926 width=17) (actual time=0.032..182.321 rows=1,000,000 loops=1)