explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 4kdr

Settings
# exclusive inclusive rows x rows loops node
1. 0.021 10.215 ↓ 3.0 6 1

HashAggregate (cost=12,539.60..12,539.63 rows=2 width=80) (actual time=10.212..10.215 rows=6 loops=1)

  • Group Key: simple_rule.condition_id, simple_rule.condition_str
2.          

CTE simple_condition

3. 1.997 1.997 ↓ 2.1 1,757 1

Index Scan using condition_rule_set_id_idx on condition (cost=0.43..1,676.39 rows=820 width=64) (actual time=0.022..1.997 rows=1,757 loops=1)

  • Index Cond: (rule_set_id = 'f1807ccd-d3e3-4dbb-a502-43b089648b69'::uuid)
  • Filter: ((type)::text <> 'AND'::text)
4.          

CTE simple_rule

5. 1.496 10.147 ↓ 8.0 8 1

Nested Loop (cost=0.43..5,867.07 rows=1 width=154) (actual time=2.358..10.147 rows=8 loops=1)

6. 3.380 3.380 ↓ 2.1 1,757 1

CTE Scan on simple_condition (cost=0.00..16.40 rows=820 width=48) (actual time=0.024..3.380 rows=1,757 loops=1)

7. 5.271 5.271 ↓ 0.0 0 1,757

Index Scan using idx_condition_id on rule (cost=0.43..7.12 rows=1 width=122) (actual time=0.003..0.003 rows=0 loops=1,757)

  • Index Cond: (condition_id = simple_condition.id)
  • Filter: (((resolution)::text = 'ACTIVE'::text) AND (project_id = 'a28f611f-b1cd-4471-92fb-38eb1275ae99'::uuid))
  • Rows Removed by Filter: 1
8.          

CTE compound_condition

9. 0.001 0.031 ↓ 0.0 0 1

GroupAggregate (cost=4,624.12..4,625.10 rows=49 width=64) (actual time=0.031..0.031 rows=0 loops=1)

  • Group Key: condition_1.id
10. 0.004 0.030 ↓ 0.0 0 1

Sort (cost=4,624.12..4,624.24 rows=49 width=64) (actual time=0.030..0.030 rows=0 loops=1)

  • Sort Key: condition_1.id
  • Sort Method: quicksort Memory: 25kB
11. 0.005 0.026 ↓ 0.0 0 1

Hash Join (cost=4,601.75..4,622.74 rows=49 width=64) (actual time=0.025..0.026 rows=0 loops=1)

  • Hash Cond: (simple_condition_1.id = condition_edge.contained_condition_id)
12. 0.001 0.001 ↑ 820.0 1 1

CTE Scan on simple_condition simple_condition_1 (cost=0.00..16.40 rows=820 width=48) (actual time=0.001..0.001 rows=1 loops=1)

13. 0.001 0.020 ↓ 0.0 0 1

Hash (cost=4,584.81..4,584.81 rows=1,355 width=48) (actual time=0.019..0.020 rows=0 loops=1)

  • Buckets: 2048 Batches: 1 Memory Usage: 16kB
14. 0.001 0.019 ↓ 0.0 0 1

Nested Loop (cost=1.35..4,584.81 rows=1,355 width=48) (actual time=0.019..0.019 rows=0 loops=1)

15. 0.018 0.018 ↓ 0.0 0 1

Index Scan using unique_condition_with_project_id on condition condition_1 (cost=0.93..894.86 rows=855 width=32) (actual time=0.018..0.018 rows=0 loops=1)

  • Index Cond: ((rule_set_id = 'f1807ccd-d3e3-4dbb-a502-43b089648b69'::uuid) AND ((type)::text = 'AND'::text))
16. 0.000 0.000 ↓ 0.0 0

Index Scan using condition_edge_compound_condition_id_idx on condition_edge (cost=0.43..4.29 rows=3 width=32) (never executed)

  • Index Cond: (compound_condition_id = condition_1.id)
17.          

CTE compound_rule

18. 0.000 0.032 ↓ 0.0 0 1

Nested Loop (cost=0.43..370.98 rows=1 width=154) (actual time=0.032..0.032 rows=0 loops=1)

19. 0.032 0.032 ↓ 0.0 0 1

CTE Scan on compound_condition (cost=0.00..0.98 rows=49 width=48) (actual time=0.031..0.032 rows=0 loops=1)

20. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_condition_id on rule rule_1 (cost=0.43..7.54 rows=1 width=122) (never executed)

  • Index Cond: (condition_id = compound_condition.id)
  • Filter: (((resolution)::text = 'ACTIVE'::text) AND (project_id = 'a28f611f-b1cd-4471-92fb-38eb1275ae99'::uuid))
21. 0.004 10.194 ↓ 4.0 8 1

Append (cost=0.00..0.05 rows=2 width=80) (actual time=2.361..10.194 rows=8 loops=1)

22. 10.157 10.157 ↓ 8.0 8 1

CTE Scan on simple_rule (cost=0.00..0.02 rows=1 width=80) (actual time=2.360..10.157 rows=8 loops=1)

23. 0.033 0.033 ↓ 0.0 0 1

CTE Scan on compound_rule (cost=0.00..0.02 rows=1 width=80) (actual time=0.032..0.033 rows=0 loops=1)

Planning time : 0.714 ms
Execution time : 10.334 ms