explain.depesz.com

PostgreSQL's explain analyze made readable

Result: PNfs

Settings
# exclusive inclusive rows x rows loops node
1. 0.027 14,713.263 ↑ 1.0 100 1

Limit (cost=69,112.05..69,112.30 rows=100 width=350) (actual time=14,713.232..14,713.263 rows=100 loops=1)

2. 0.581 14,713.236 ↑ 2.0 100 1

Sort (cost=69,112.05..69,112.55 rows=200 width=350) (actual time=14,713.230..14,713.236 rows=100 loops=1)

  • Sort Key: p.uuid, p.first_name, p.last_name, p.valid_from DESC, p.sequence DESC
  • Sort Method: top-N heapsort Memory: 91kB
3. 1.078 14,712.655 ↓ 14.2 2,834 1

Unique (cost=68,636.15..69,102.41 rows=200 width=350) (actual time=14,711.097..14,712.655 rows=2,834 loops=1)

4. 3.806 14,711.577 ↑ 32.9 2,834 1

Sort (cost=68,636.15..68,869.28 rows=93,252 width=350) (actual time=14,711.094..14,711.577 rows=2,834 loops=1)

  • Sort Key: p.uuid
  • Sort Method: quicksort Memory: 2,018kB
5. 0.519 14,707.771 ↑ 32.9 2,834 1

Subquery Scan on p (cost=43,146.93..51,306.48 rows=93,252 width=350) (actual time=14,686.625..14,707.771 rows=2,834 loops=1)

6. 19.211 14,707.252 ↑ 32.9 2,834 1

GroupAggregate (cost=43,146.93..50,373.96 rows=93,252 width=372) (actual time=14,686.623..14,707.252 rows=2,834 loops=1)

  • Group Key: p_1.organization_uuid, p_1.revision_uuid, pr.valid_range, pr.sequence, s.name
7.          

Initplan (for GroupAggregate)

8. 0.001 0.021 ↓ 0.0 0 1

Append (cost=0.41..3.44 rows=1 width=0) (actual time=0.021..0.021 rows=0 loops=1)

9. 0.020 0.020 ↓ 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..3.44 rows=1 width=0) (actual time=0.020..0.020 rows=0 loops=1)

  • Index Cond: ((organization_uuid = '9179fd37-1322-4957-8a99-7e2056388b4f'::uuid) AND (person_uuid = '26b9d4a9-10ff-4389-a60b-6febbfd8ffc8'::uuid))
  • Filter: (is_company_admin AND upper_inf(valid_range))
10. 22.046 14,688.020 ↑ 10.8 8,655 1

Sort (cost=43,143.49..43,376.62 rows=93,252 width=381) (actual time=14,686.556..14,688.020 rows=8,655 loops=1)

  • Sort Key: p_1.revision_uuid, pr.valid_range, pr.sequence, s.name
  • Sort Method: quicksort Memory: 4,813kB
11. 7.411 14,665.974 ↑ 10.8 8,655 1

Nested Loop Left Join (cost=16,420.76..24,994.83 rows=93,252 width=381) (actual time=1,594.315..14,665.974 rows=8,655 loops=1)

12. 9.782 14,658.563 ↑ 1.8 8,655 1

Hash Left Join (cost=16,420.47..23,818.26 rows=15,542 width=370) (actual time=1,593.347..14,658.563 rows=8,655 loops=1)

  • Hash Cond: (p_1.person_uuid = pr.person_uuid)
13. 7,729.846 13,232.389 ↓ 11.4 6,011 1

Nested Loop Left Join (cost=10,640.18..17,493.44 rows=526 width=291) (actual time=176.912..13,232.389 rows=6,011 loops=1)

  • Join Filter: (tpr.person_uuid = p_1.person_uuid)
  • Rows Removed by Join Filter: 103,684,214
  • Filter: ((p_1.person_uuid = '26b9d4a9-10ff-4389-a60b-6febbfd8ffc8'::uuid) OR $0 OR (tpr.person_uuid IS NOT NULL))
  • Rows Removed by Filter: 9,491
14. 3.604 227.443 ↓ 23.3 12,325 1

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

  • Join Filter: (adm.person_uuid = p_1.person_uuid)
15. 2.557 211.514 ↓ 11.7 12,325 1

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

16. 78.568 208.957 ↓ 11.7 12,325 1

Bitmap Heap Scan on persons_org_part_default p_1 (cost=10,639.12..16,129.59 rows=1,056 width=291) (actual time=130.537..208.957 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=641
17. 1.055 130.389 ↓ 0.0 0 1

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

18. 3.188 3.188 ↑ 1.1 19,762 1

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

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

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

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

21. 0.003 6.940 ↓ 0.0 0 1

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

22. 6.937 6.937 ↓ 0.0 0 1

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

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

24. 0.864 23.860 ↓ 1,402.2 8,413 1

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

25. 0.829 1.606 ↓ 31.0 31 1

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

  • Join Filter: (spr.roles @> ((('[""'::text || (rr.source_role_uuid)::text) || '""]'::text))::jsonb)
  • Rows Removed by Join Filter: 619
26. 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)

27. 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.053..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
28. 0.720 0.720 ↓ 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.060..0.720 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
29. 0.713 21.390 ↓ 45.2 271 31

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

30. 18.972 20.677 ↓ 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.071..0.667 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
31. 1.705 1.705 ↓ 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.055..0.055 rows=273 loops=31)

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

Hash (cost=5,706.50..5,706.50 rows=5,904 width=95) (actual time=1,416.392..1,416.392 rows=19,319 loops=1)

  • Buckets: 32,768 (originally 8192) Batches: 1 (originally 1) Memory Usage: 2,551kB
33. 1,321.814 1,403.889 ↓ 3.3 19,319 1

Nested Loop Left Join (cost=2.42..5,706.50 rows=5,904 width=95) (actual time=0.255..1,403.889 rows=19,319 loops=1)

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

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

35. 10.049 10.049 ↓ 3.0 17,604 1

Seq Scan on person_roles_org_part_72 pr (cost=0.00..604.69 rows=5,904 width=81) (actual time=0.022..10.049 rows=17,604 loops=1)

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

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

37. 0.079 0.134 ↓ 3.0 83 1

Bitmap Heap Scan on roles role (cost=2.42..112.85 rows=28 width=57) (actual time=0.077..0.134 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
38. 0.055 0.055 ↓ 1.0 86 1

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

  • Index Cond: (organization_uuid = '9179fd37-1322-4957-8a99-7e2056388b4f'::uuid)
39. 0.000 0.000 ↑ 6.0 1 8,655

Materialize (cost=0.28..10.93 rows=6 width=11) (actual time=0.000..0.000 rows=1 loops=8,655)

40. 0.961 0.961 ↑ 6.0 1 1

Index Scan using sites_org_valid_range_gist on sites s (cost=0.28..10.90 rows=6 width=11) (actual time=0.960..0.961 rows=1 loops=1)

  • Index 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)
Planning time : 218.369 ms
Execution time : 14,714.660 ms