explain.depesz.com

PostgreSQL's explain analyze made readable

Result: sue4 : person count - 2nd run

Settings
# exclusive inclusive rows x rows loops node
1. 8.853 14,000.042 ↑ 1.0 1 1

Aggregate (cost=23,861.23..23,861.24 rows=1 width=8) (actual time=14,000.042..14,000.042 rows=1 loops=1)

2.          

Initplan (for Aggregate)

3. 0.001 0.022 ↓ 0.0 0 1

Append (cost=0.41..4.12 rows=1 width=0) (actual time=0.022..0.022 rows=0 loops=1)

4. 0.021 0.021 ↓ 0.0 0 1

Index Scan using person_roles_org_part_72_organization_uuid_person_uuid_sequ_idx on person_roles_org_part_72 (cost=0.41..4.11 rows=1 width=0) (actual time=0.021..0.021 rows=0 loops=1)

  • Index Cond: ((organization_uuid = '9179fd37-1322-4957-8a99-7e2056388b4f'::uuid) AND (person_uuid = '981387e3-9d1a-4d83-bd44-8866e911710b'::uuid))
  • Filter: (is_company_admin AND upper_inf(valid_range))
  • Rows Removed by Filter: 2
5. 7.883 13,991.167 ↑ 1.8 8,655 1

Hash Left Join (cost=16,420.47..23,818.26 rows=15,542 width=16) (actual time=1,477.417..13,991.167 rows=8,655 loops=1)

  • Hash Cond: (p.person_uuid = pr.person_uuid)
6. 7,289.570 12,640.010 ↓ 11.4 6,011 1

Nested Loop Left Join (cost=10,640.18..17,493.44 rows=526 width=16) (actual time=134.086..12,640.010 rows=6,011 loops=1)

  • Join Filter: (tpr.person_uuid = p.person_uuid)
  • Rows Removed by Join Filter: 103,684,214
  • Filter: ((p.person_uuid = '981387e3-9d1a-4d83-bd44-8866e911710b'::uuid) OR $0 OR (tpr.person_uuid IS NOT NULL))
  • Rows Removed by Filter: 9,491
7. 10.783 173.940 ↓ 23.3 12,325 1

Nested Loop Anti Join (cost=10,639.12..16,755.42 rows=528 width=16) (actual time=100.313..173.940 rows=12,325 loops=1)

  • Join Filter: (adm.person_uuid = p.person_uuid)
8. 1.953 163.157 ↓ 11.7 12,325 1

Append (cost=10,639.12..16,134.87 rows=1,056 width=16) (actual time=95.467..163.157 rows=12,325 loops=1)

9. 65.870 161.204 ↓ 11.7 12,325 1

Bitmap Heap Scan on persons_org_part_default p (cost=10,639.12..16,129.59 rows=1,056 width=16) (actual time=95.466..161.204 rows=12,325 loops=1)

  • Recheck Cond: ((organization_uuid = '9179fd37-1322-4957-8a99-7e2056388b4f'::uuid) AND (valid_range @> '2019-09-29 01:19:31+00'::timestamp with time zone))
  • Filter: ((is_visible IS TRUE) AND (((first_name)::text ~~* '%st%'::text) OR ((last_name)::text ~~* '%st%'::text) OR ((target_name)::text ~~* '%st%'::text) OR ((web_login)::text ~~ '%st%'::text)))
  • Rows Removed by Filter: 5,194
  • Heap Blocks: exact=652
10. 0.684 95.334 ↓ 0.0 0 1

BitmapAnd (cost=10,639.12..10,639.12 rows=4,013 width=0) (actual time=95.334..95.334 rows=0 loops=1)

11. 2.423 2.423 ↑ 1.1 19,775 1

Bitmap Index Scan on persons_org_part_default_pkey (cost=0.00..359.83 rows=21,120 width=0) (actual time=2.423..2.423 rows=19,775 loops=1)

  • Index Cond: (organization_uuid = '9179fd37-1322-4957-8a99-7e2056388b4f'::uuid)
12. 92.227 92.227 ↑ 1.0 433,828 1

Bitmap Index Scan on persons_org_part_default_valid_range_idx (cost=0.00..10,278.51 rows=444,213 width=0) (actual time=92.227..92.227 rows=433,828 loops=1)

  • Index Cond: (valid_range @> '2019-09-29 01:19:31+00'::timestamp with time zone)
13. 0.000 0.000 ↓ 0.0 0 12,325

Materialize (cost=0.00..604.70 rows=1 width=16) (actual time=0.000..0.000 rows=0 loops=12,325)

14. 0.003 4.833 ↓ 0.0 0 1

Append (cost=0.00..604.70 rows=1 width=16) (actual time=4.833..4.833 rows=0 loops=1)

15. 4.830 4.830 ↓ 0.0 0 1

Seq Scan on person_roles_org_part_72 adm (cost=0.00..604.69 rows=1 width=16) (actual time=4.830..4.830 rows=0 loops=1)

  • Filter: (is_super_admin AND upper_inf(valid_range) AND (organization_uuid = '9179fd37-1322-4957-8a99-7e2056388b4f'::uuid))
  • Rows Removed by Filter: 17,726
16. 5,159.364 5,176.500 ↓ 1,402.2 8,413 12,325

Materialize (cost=1.06..682.60 rows=6 width=16) (actual time=0.000..0.420 rows=8,413 loops=12,325)

17. 0.791 17.136 ↓ 1,402.2 8,413 1

Nested Loop (cost=1.06..682.57 rows=6 width=16) (actual time=0.283..17.136 rows=8,413 loops=1)

18. 0.619 1.155 ↓ 31.0 31 1

Nested Loop (cost=0.84..678.75 rows=1 width=16) (actual time=0.183..1.155 rows=31 loops=1)

  • Join Filter: (spr.roles @> ((('[""'::text || (rr.source_role_uuid)::text) || '""]'::text))::jsonb)
  • Rows Removed by Join Filter: 619
19. 0.002 0.057 ↑ 1.0 1 1

Append (cost=0.41..4.12 rows=1 width=43) (actual time=0.054..0.057 rows=1 loops=1)

20. 0.055 0.055 ↑ 1.0 1 1

Index Scan using person_roles_org_part_72_organization_uuid_person_uuid_sequ_idx on person_roles_org_part_72 spr (cost=0.41..4.11 rows=1 width=43) (actual time=0.054..0.055 rows=1 loops=1)

  • Index Cond: ((organization_uuid = '9179fd37-1322-4957-8a99-7e2056388b4f'::uuid) AND (person_uuid = '981387e3-9d1a-4d83-bd44-8866e911710b'::uuid))
  • Filter: upper_inf(valid_range)
  • Rows Removed by Filter: 1
21. 0.479 0.479 ↓ 3.8 650 1

Index Scan using role_on_role_organization_uuid_idx on role_on_role rr (cost=0.42..669.93 rows=171 width=32) (actual time=0.057..0.479 rows=650 loops=1)

  • Index Cond: (organization_uuid = '9179fd37-1322-4957-8a99-7e2056388b4f'::uuid)
  • Filter: ((can_edit_person OR can_view_person OR can_use_person) AND upper_inf(valid_range))
  • Rows Removed by Filter: 20
22. 0.682 15.190 ↓ 45.2 271 31

Append (cost=0.22..3.76 rows=6 width=59) (actual time=0.050..0.490 rows=271 loops=31)

23. 13.485 14.508 ↓ 45.2 271 31

Bitmap Heap Scan on person_roles_org_part_72 tpr (cost=0.22..3.73 rows=6 width=59) (actual time=0.048..0.468 rows=271 loops=31)

  • Recheck Cond: (roles @> ((('[""'::text || (rr.target_role_uuid)::text) || '""]'::text))::jsonb)
  • Filter: (upper_inf(valid_range) AND (organization_uuid = '9179fd37-1322-4957-8a99-7e2056388b4f'::uuid))
  • Rows Removed by Filter: 2
  • Heap Blocks: exact=2,676
24. 1.023 1.023 ↓ 15.2 273 31

Bitmap Index Scan on person_roles_org_part_72_roles_idx (cost=0.00..0.22 rows=18 width=0) (actual time=0.033..0.033 rows=273 loops=31)

  • Index Cond: (roles @> ((('[""'::text || (rr.target_role_uuid)::text) || '""]'::text))::jsonb)
25. 9.408 1,343.274 ↓ 3.3 19,319 1

Hash (cost=5,706.50..5,706.50 rows=5,904 width=16) (actual time=1,343.273..1,343.274 rows=19,319 loops=1)

  • Buckets: 32,768 (originally 8192) Batches: 1 (originally 1) Memory Usage: 1,162kB
26. 1,253.358 1,333.866 ↓ 3.3 19,319 1

Nested Loop Left Join (cost=2.42..5,706.50 rows=5,904 width=16) (actual time=0.284..1,333.866 rows=19,319 loops=1)

  • Join Filter: (pr.roles @> ((('[""'::text || (role.role_uuid)::text) || '""]'::text))::jsonb)
  • Rows Removed by Join Filter: 1,444,112
27. 1.659 10.092 ↓ 3.0 17,604 1

Append (cost=0.00..634.21 rows=5,904 width=59) (actual time=0.027..10.092 rows=17,604 loops=1)

28. 8.433 8.433 ↓ 3.0 17,604 1

Seq Scan on person_roles_org_part_72 pr (cost=0.00..604.69 rows=5,904 width=59) (actual time=0.026..8.433 rows=17,604 loops=1)

  • Filter: (upper_inf(valid_range) AND (organization_uuid = '9179fd37-1322-4957-8a99-7e2056388b4f'::uuid))
  • Rows Removed by Filter: 122
29. 70.283 70.416 ↓ 3.0 83 17,604

Materialize (cost=2.42..112.99 rows=28 width=16) (actual time=0.000..0.004 rows=83 loops=17,604)

30. 0.071 0.133 ↓ 3.0 83 1

Bitmap Heap Scan on roles role (cost=2.42..112.85 rows=28 width=16) (actual time=0.077..0.133 rows=83 loops=1)

  • Recheck Cond: (organization_uuid = '9179fd37-1322-4957-8a99-7e2056388b4f'::uuid)
  • Filter: upper_inf(valid_range)
  • Rows Removed by Filter: 3
  • Heap Blocks: exact=4
31. 0.062 0.062 ↓ 1.0 86 1

Bitmap Index Scan on roles_organization_uuid_idx (cost=0.00..2.41 rows=83 width=0) (actual time=0.062..0.062 rows=86 loops=1)

  • Index Cond: (organization_uuid = '9179fd37-1322-4957-8a99-7e2056388b4f'::uuid)
Planning time : 131.945 ms
Execution time : 14,000.810 ms