explain.depesz.com

PostgreSQL's explain analyze made readable

Result: eo3Y : person count - run 1

Settings
# exclusive inclusive rows x rows loops node
1. 9.614 16,312.581 ↑ 1.0 1 1

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

2.          

Initplan (for Aggregate)

3. 0.001 0.030 ↓ 0.0 0 1

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

4. 0.029 0.029 ↓ 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.029..0.029 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. 8.739 16,302.937 ↑ 1.8 8,655 1

Hash Left Join (cost=16,420.47..23,818.26 rows=15,542 width=16) (actual time=2,560.857..16,302.937 rows=8,655 loops=1)

  • Hash Cond: (p.person_uuid = pr.person_uuid)
6. 8,096.965 14,653.096 ↓ 11.4 6,011 1

Nested Loop Left Join (cost=10,640.18..17,493.44 rows=526 width=16) (actual time=919.711..14,653.096 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. 4.354 677.106 ↓ 23.3 12,325 1

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

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

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

9. 85.556 189.840 ↓ 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=104.420..189.840 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.526 104.284 ↓ 0.0 0 1

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

11. 2.508 2.508 ↑ 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.507..2.508 rows=19,775 loops=1)

  • Index Cond: (organization_uuid = '9179fd37-1322-4957-8a99-7e2056388b4f'::uuid)
12. 101.250 101.250 ↑ 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=101.250..101.250 rows=433,828 loops=1)

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

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

14. 0.003 477.611 ↓ 0.0 0 1

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

15. 477.608 477.608 ↓ 0.0 0 1

Seq Scan on person_roles_org_part_72 adm (cost=0.00..604.69 rows=1 width=16) (actual time=477.608..477.608 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,560.399 5,879.025 ↓ 1,402.2 8,413 12,325

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

17. 1.014 318.626 ↓ 1,402.2 8,413 1

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

18. 1.237 249.877 ↓ 31.0 31 1

Nested Loop (cost=0.84..678.75 rows=1 width=16) (actual time=74.906..249.877 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.384 ↑ 1.0 1 1

Append (cost=0.41..4.12 rows=1 width=43) (actual time=0.381..0.384 rows=1 loops=1)

20. 0.382 0.382 ↑ 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.380..0.382 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. 248.256 248.256 ↓ 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=73.389..248.256 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.899 67.735 ↓ 45.2 271 31

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

23. 18.941 66.836 ↓ 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=1.566..2.156 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. 47.895 47.895 ↓ 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=1.545..1.545 rows=273 loops=31)

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

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

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

Nested Loop Left Join (cost=2.42..5,706.50 rows=5,904 width=16) (actual time=48.320..1,628.812 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. 2.060 14.914 ↓ 3.0 17,604 1

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

28. 12.854 12.854 ↓ 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.022..12.854 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. 95.001 158.436 ↓ 3.0 83 17,604

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

30. 38.205 63.435 ↓ 3.0 83 1

Bitmap Heap Scan on roles role (cost=2.42..112.85 rows=28 width=16) (actual time=46.543..63.435 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. 25.230 25.230 ↓ 1.0 86 1

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

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