explain.depesz.com

PostgreSQL's explain analyze made readable

Result: SAjM

Settings
# exclusive inclusive rows x rows loops node
1. 0.177 14.054 ↓ 156.0 156 1

Nested Loop (cost=81.68..102.76 rows=1 width=16) (actual time=10.990..14.054 rows=156 loops=1)

  • Join Filter: (organizational_unit.organizational_hierarchy_id = organizational_hierarchy.id)
2. 0.005 13.877 ↓ 156.0 156 1

Nested Loop (cost=81.68..101.73 rows=1 width=32) (actual time=10.985..13.877 rows=156 loops=1)

3. 0.020 13.716 ↓ 156.0 156 1

Nested Loop (cost=81.54..93.48 rows=1 width=32) (actual time=10.979..13.716 rows=156 loops=1)

4. 0.013 0.013 ↑ 1.0 1 1

Seq Scan on person_assignment (cost=0.00..1.36 rows=1 width=64) (actual time=0.012..0.013 rows=1 loops=1)

  • Filter: (person_id = '8e459ecd-2208-44b9-836a-b9bbf182ec03'::uuid)
  • Rows Removed by Filter: 28
5. 0.174 13.683 ↓ 156.0 156 1

Nested Loop (cost=81.54..92.11 rows=1 width=48) (actual time=10.965..13.683 rows=156 loops=1)

  • Join Filter: (person_assignment.organizational_unit_id = organizational_unit.id)
  • Rows Removed by Join Filter: 1716
6. 0.015 0.015 ↓ 26.0 26 1

Seq Scan on organizational_unit (cost=0.00..1.32 rows=1 width=64) (actual time=0.006..0.015 rows=26 loops=1)

  • Filter: (state = 'ACTIVE'::text)
7. 0.000 13.494 ↓ 72.0 72 26

Nested Loop Anti Join (cost=81.54..90.77 rows=1 width=16) (actual time=0.288..0.519 rows=72 loops=26)

8. 0.390 9.750 ↓ 72.0 72 26

Subquery Scan on alias_755097 (cost=81.26..82.30 rows=1 width=16) (actual time=0.285..0.375 rows=72 loops=26)

  • Filter: (alias_755097.r = 1)
  • Rows Removed by Filter: 76
9. 1.768 9.360 ↓ 4.6 148 26

WindowAgg (cost=81.26..81.90 rows=32 width=44) (actual time=0.284..0.360 rows=148 loops=26)

10. 1.092 7.592 ↓ 4.6 148 26

Sort (cost=81.26..81.34 rows=32 width=20) (actual time=0.282..0.292 rows=148 loops=26)

  • Sort Key: employee.person_id, employee.sort_code
  • Sort Method: quicksort Memory: 25kB
11. 0.468 6.500 ↓ 4.6 148 26

Result (cost=72.42..80.46 rows=32 width=20) (actual time=0.200..0.250 rows=148 loops=26)

  • One-Time Filter: ((person_assignment.state = 'ACTIVE'::text) AND (person_assignment.person_id = '8e459ecd-2208-44b9-836a-b9bbf182ec03'::uuid))
12. 0.676 6.032 ↓ 4.6 148 26

Hash Join (cost=72.42..80.46 rows=32 width=20) (actual time=0.197..0.232 rows=148 loops=26)

  • Hash Cond: (employee.organization_id = organization_assignment.organization_id)
13. 0.312 0.312 ↑ 1.0 167 12

Seq Scan on employee (cost=0.00..7.09 rows=167 width=36) (actual time=0.002..0.026 rows=167 loops=12)

  • Filter: (state = 'ACTIVE'::text)
14. 1.274 5.044 ↓ 4.6 396 26

Hash (cost=71.34..71.34 rows=86 width=16) (actual time=0.194..0.194 rows=396 loops=26)

  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
15. 1.332 3.770 ↓ 4.6 396 26

Nested Loop (cost=19.75..71.34 rows=86 width=16) (actual time=0.023..0.145 rows=396 loops=26)

16. 0.182 0.182 ↓ 4.0 4 26

Seq Scan on organizational_unit ou2 (cost=0.00..1.39 rows=1 width=16) (actual time=0.004..0.007 rows=4 loops=26)

  • Filter: ((materialized_path @> organizational_unit.materialized_path) AND (state = 'ACTIVE'::text))
  • Rows Removed by Filter: 22
17. 1.692 2.256 ↑ 4.1 110 94

Bitmap Heap Scan on organization_assignment (cost=19.75..65.47 rows=448 width=32) (actual time=0.007..0.024 rows=110 loops=94)

  • Recheck Cond: ((organizational_unit_id = ou2.id) AND (state = 'ACTIVE'::text))
  • Heap Blocks: exact=897
18. 0.564 0.564 ↑ 4.1 110 94

Bitmap Index Scan on organizational_assignment_org_unit_id_org_id_idx (cost=0.00..19.64 rows=448 width=0) (actual time=0.006..0.006 rows=110 loops=94)

  • Index Cond: (organizational_unit_id = ou2.id)
19. 0.000 3.744 ↓ 0.0 0 1,872

Nested Loop (cost=0.28..8.47 rows=1 width=16) (actual time=0.002..0.002 rows=0 loops=1,872)

20. 1.872 1.872 ↑ 1.0 1 1,872

Index Scan using person_to_person_type_person_idx on person_to_person_type (cost=0.14..8.16 rows=1 width=32) (actual time=0.001..0.001 rows=1 loops=1,872)

  • Index Cond: (person_id = alias_755097.person_id)
21. 1.872 1.872 ↓ 0.0 0 1,872

Index Scan using person_type_pkey on person_type (cost=0.14..0.22 rows=1 width=16) (actual time=0.001..0.001 rows=0 loops=1,872)

  • Index Cond: (id = person_to_person_type.person_type_id)
  • Filter: (base_type = 'INTERNAL'::text)
  • Rows Removed by Filter: 1
22. 0.156 0.156 ↑ 1.0 1 156

Index Only Scan using person_id_state_idx on person (cost=0.14..8.16 rows=1 width=16) (actual time=0.001..0.001 rows=1 loops=156)

  • Index Cond: (id = alias_755097.person_id)
  • Heap Fetches: 156
23. 0.000 0.000 ↑ 1.0 1 156

Seq Scan on organizational_hierarchy (cost=0.00..1.01 rows=1 width=16) (actual time=0.000..0.000 rows=1 loops=156)

  • Filter: (state = 'ACTIVE'::text)
Planning time : 2.166 ms
Execution time : 14.169 ms