explain.depesz.com

PostgreSQL's explain analyze made readable

Result: p7y2

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=70,797.42..88,603.65 rows=396,587 width=0) (actual rows= loops=)

  • Merge Cond: (users.id = b.user_id)
2.          

CTE a

3. 0.000 0.000 ↓ 0.0

HashAggregate (cost=37,722.19..37,876.73 rows=51,514 width=12) (actual rows= loops=)

  • Group Key: baskets.user_id
4. 0.000 0.000 ↓ 0.0

Seq Scan on baskets (cost=0.00..35,842.39 rows=1,879,797 width=8) (actual rows= loops=)

5.          

CTE b

6. 0.000 0.000 ↓ 0.0

HashAggregate (cost=30,757.16..30,886.06 rows=42,968 width=12) (actual rows= loops=)

  • Group Key: orders.user_id
7. 0.000 0.000 ↓ 0.0

Seq Scan on orders (cost=0.00..29,969.62 rows=787,539 width=8) (actual rows= loops=)

8. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=1,115.50..18,551.57 rows=396,587 width=4) (actual rows= loops=)

  • Merge Cond: (users.id = a.user_id)
9. 0.000 0.000 ↓ 0.0

Index Only Scan using users_pkey on users (cost=0.08..17,031.80 rows=396,587 width=4) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Sort (cost=1,115.42..1,141.17 rows=51,514 width=4) (actual rows= loops=)

  • Sort Key: a.user_id
11. 0.000 0.000 ↓ 0.0

CTE Scan on a (cost=0.00..309.08 rows=51,514 width=4) (actual rows= loops=)

12. 0.000 0.000 ↓ 0.0

Sort (cost=919.13..940.61 rows=42,968 width=4) (actual rows= loops=)

  • Sort Key: b.user_id
13. 0.000 0.000 ↓ 0.0

CTE Scan on b (cost=0.00..257.81 rows=42,968 width=4) (actual rows= loops=)