explain.depesz.com

PostgreSQL's explain analyze made readable

Result: MMMm

Settings
# exclusive inclusive rows x rows loops node
1. 0.030 0.422 ↑ 2.8 5 1

Hash Join (cost=74.60..77.37 rows=14 width=77) (actual time=0.209..0.422 rows=5 loops=1)

  • Hash Cond: (selected_events.id = events.id)
2.          

CTE path_upwards

3. 0.019 0.145 ↑ 37.0 3 1

Recursive Union (cost=0.00..34.58 rows=111 width=24) (actual time=0.017..0.145 rows=3 loops=1)

4. 0.008 0.008 ↑ 1.0 1 1

Seq Scan on events events_1 (cost=0.00..1.18 rows=1 width=24) (actual time=0.007..0.008 rows=1 loops=1)

  • Filter: (id = 11)
  • Rows Removed by Filter: 13
5. 0.029 0.118 ↑ 11.0 1 2

Hash Join (cost=1.67..3.12 rows=11 width=24) (actual time=0.057..0.059 rows=1 loops=2)

  • Hash Cond: (link.parent_id = parent_event.id)
6. 0.048 0.066 ↑ 11.0 1 2

Hash Join (cost=0.35..1.65 rows=11 width=8) (actual time=0.032..0.033 rows=1 loops=2)

  • Hash Cond: (link.child_id = current.id)
7. 0.004 0.004 ↑ 1.2 12 2

Seq Scan on event_links link (cost=0.00..1.14 rows=14 width=16) (actual time=0.002..0.002 rows=12 loops=2)

8. 0.010 0.014 ↑ 10.0 1 2

Hash (cost=0.22..0.22 rows=10 width=8) (actual time=0.007..0.007 rows=1 loops=2)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
9. 0.004 0.004 ↑ 10.0 1 2

WorkTable Scan on path_upwards current (cost=0.00..0.22 rows=10 width=8) (actual time=0.002..0.002 rows=1 loops=2)

  • Filter: (numerator <> denominator)
10. 0.015 0.023 ↑ 1.0 14 1

Hash (cost=1.14..1.14 rows=14 width=24) (actual time=0.023..0.023 rows=14 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
11. 0.008 0.008 ↑ 1.0 14 1

Seq Scan on events parent_event (cost=0.00..1.14 rows=14 width=24) (actual time=0.002..0.008 rows=14 loops=1)

12.          

CTE first_node

13. 0.003 0.152 ↑ 1.0 1 1

Limit (cost=0.00..2.50 rows=1 width=8) (actual time=0.151..0.152 rows=1 loops=1)

14. 0.149 0.149 ↑ 1.0 1 1

CTE Scan on path_upwards (cost=0.00..2.50 rows=1 width=8) (actual time=0.149..0.149 rows=1 loops=1)

  • Filter: (numerator = denominator)
  • Rows Removed by Filter: 2
15.          

CTE path_downwards

16. 0.015 0.364 ↑ 22.2 5 1

Recursive Union (cost=0.02..36.20 rows=111 width=24) (actual time=0.164..0.364 rows=5 loops=1)

17. 0.014 0.166 ↑ 1.0 1 1

Seq Scan on events events_2 (cost=0.02..1.20 rows=1 width=24) (actual time=0.162..0.166 rows=1 loops=1)

  • Filter: (id = $4)
  • Rows Removed by Filter: 13
18.          

Initplan (for Seq Scan)

19. 0.152 0.152 ↑ 1.0 1 1

CTE Scan on first_node (cost=0.00..0.02 rows=1 width=8) (actual time=0.151..0.152 rows=1 loops=1)

20. 0.037 0.183 ↑ 5.5 2 3

Hash Join (cost=1.64..3.28 rows=11 width=24) (actual time=0.054..0.061 rows=2 loops=3)

  • Hash Cond: (link_1.child_id = child_event.id)
21. 0.018 0.111 ↑ 5.5 2 3

Nested Loop (cost=0.33..1.81 rows=11 width=8) (actual time=0.030..0.037 rows=2 loops=3)

  • Join Filter: ((current_1.numerator <> current_1.denominator) OR (current_1.id = first_node_1.id))
  • Rows Removed by Join Filter: 0
22. 0.000 0.000 ↑ 1.0 1 3

CTE Scan on first_node first_node_1 (cost=0.00..0.02 rows=1 width=8) (actual time=0.000..0.000 rows=1 loops=3)

23. 0.066 0.093 ↑ 5.5 2 3

Hash Join (cost=0.33..1.63 rows=11 width=32) (actual time=0.026..0.031 rows=2 loops=3)

  • Hash Cond: (link_1.parent_id = current_1.id)
24. 0.015 0.015 ↑ 1.0 14 3

Seq Scan on event_links link_1 (cost=0.00..1.14 rows=14 width=16) (actual time=0.002..0.005 rows=14 loops=3)

25. 0.009 0.012 ↑ 5.0 2 3

Hash (cost=0.20..0.20 rows=10 width=24) (actual time=0.004..0.004 rows=2 loops=3)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
26. 0.003 0.003 ↑ 5.0 2 3

WorkTable Scan on path_downwards current_1 (cost=0.00..0.20 rows=10 width=24) (actual time=0.001..0.001 rows=2 loops=3)

27. 0.026 0.035 ↑ 1.0 14 1

Hash (cost=1.14..1.14 rows=14 width=24) (actual time=0.035..0.035 rows=14 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
28. 0.009 0.009 ↑ 1.0 14 1

Seq Scan on events child_event (cost=0.00..1.14 rows=14 width=24) (actual time=0.003..0.009 rows=14 loops=1)

29. 0.374 0.374 ↑ 22.2 5 1

CTE Scan on path_downwards selected_events (cost=0.00..2.22 rows=111 width=8) (actual time=0.167..0.374 rows=5 loops=1)

30. 0.015 0.018 ↑ 1.0 14 1

Hash (cost=1.14..1.14 rows=14 width=77) (actual time=0.018..0.018 rows=14 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 10kB
31. 0.003 0.003 ↑ 1.0 14 1

Seq Scan on events (cost=0.00..1.14 rows=14 width=77) (actual time=0.002..0.003 rows=14 loops=1)

Planning time : 2.276 ms
Execution time : 0.780 ms