explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 32FA

Settings
# exclusive inclusive rows x rows loops node
1. 0.007 0.122 ↑ 2.8 5 1

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

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

CTE path_upwards

3. 0.006 0.042 ↑ 37.0 3 1

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

4. 0.004 0.004 ↑ 1.0 1 1

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

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

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

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

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

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

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

8. 0.000 0.004 ↑ 10.0 1 2

Hash (cost=0.22..0.22 rows=10 width=8) (actual time=0.002..0.002 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.001..0.002 rows=1 loops=2)

  • Filter: (numerator <> denominator)
10. 0.003 0.006 ↑ 1.0 14 1

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

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

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

12.          

CTE first_node

13. 0.000 0.045 ↑ 1.0 1 1

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

14. 0.045 0.045 ↑ 1.0 1 1

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

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

CTE path_downwards

16. 0.008 0.107 ↑ 22.2 5 1

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

17. 0.007 0.054 ↑ 1.0 1 1

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

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

Initplan (for Seq Scan)

19. 0.047 0.047 ↑ 1.0 1 1

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

20. 0.006 0.045 ↑ 5.5 2 3

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

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

Nested Loop (cost=0.33..1.81 rows=11 width=8) (actual time=0.009..0.011 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.021 0.027 ↑ 5.5 2 3

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

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

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

25. 0.003 0.003 ↑ 5.0 2 3

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

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

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

27. 0.004 0.006 ↑ 1.0 14 1

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

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

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

29. 0.109 0.109 ↑ 22.2 5 1

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

30. 0.004 0.006 ↑ 1.0 14 1

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

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

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

Planning time : 0.739 ms
Execution time : 0.201 ms