explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 6cOj : Optimization for: Optimization for: plan #P1Js; plan #PQHU

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 799.318 12,134.751 ↑ 206,000.5 1,040 1

GroupAggregate (cost=319,312,509.33..349,971,925.30 rows=214,240,537 width=186) (actual time=10,931.163..12,134.751 rows=1,040 loops=1)

  • Group Key: ufc.institute_name, ufc.user_name
  • Group Key: ufc.institute_name
  • Functions: 95
  • Options: Inlining true, Optimization true, Expressions true, Deforming true
  • Timing: Generation 19.129 ms, Inlining 39.066 ms, Optimization 1107.864 ms, Emission 790.479 ms, Total 1956.538 ms
2. 3,001.366 11,335.433 ↑ 193.4 1,134,295 1

Sort (cost=319,312,509.33..319,860,913.38 rows=219,361,620 width=126) (actual time=10,931.132..11,335.433 rows=1,134,295 loops=1)

  • Sort Key: ufc.institute_name, ufc.user_name
  • Sort Method: external merge Disk: 242,792kB
3. 91.613 8,334.067 ↑ 193.4 1,134,295 1

Subquery Scan on ufc (cost=219,325,432.22..231,938,725.37 rows=219,361,620 width=126) (actual time=7,026.875..8,334.067 rows=1,134,295 loops=1)

4. 958.267 8,242.454 ↑ 193.4 1,134,295 1

WindowAgg (cost=219,325,432.22..229,745,109.17 rows=219,361,620 width=170) (actual time=7,026.874..8,242.454 rows=1,134,295 loops=1)

5. 1,534.593 7,284.187 ↑ 193.4 1,134,295 1

Sort (cost=219,325,432.22..219,873,836.27 rows=219,361,620 width=150) (actual time=7,026.466..7,284.187 rows=1,134,295 loops=1)

  • Sort Key: tf.attendance_id, tf.target_approval_level
  • Sort Method: external merge Disk: 274,056kB
6. 638.820 5,749.594 ↑ 193.4 1,134,295 1

WindowAgg (cost=118,018,757.80..122,954,394.25 rows=219,361,620 width=150) (actual time=4,726.606..5,749.594 rows=1,134,295 loops=1)

7. 1,850.897 5,110.774 ↑ 193.4 1,134,295 1

Sort (cost=118,018,757.80..118,567,161.85 rows=219,361,620 width=142) (actual time=4,726.475..5,110.774 rows=1,134,295 loops=1)

  • Sort Key: tf.attendance_id, uracl.user_name, tf.target_approval_level
  • Sort Method: external merge Disk: 265,176kB
8. 118.161 3,259.877 ↑ 193.4 1,134,295 1

Nested Loop (cost=123,186.31..24,646,813.84 rows=219,361,620 width=142) (actual time=2,228.489..3,259.877 rows=1,134,295 loops=1)

  • Join Filter: ((uracl.institute_id = i.id) OR (uracl.institute_id IS NULL))
  • Rows Removed by Join Filter: 64,721
9. 434.003 3,075.104 ↑ 167.0 33,306 1

Merge Left Join (cost=122,735.77..14,886,314.26 rows=5,561,280 width=110) (actual time=2,223.096..3,075.104 rows=33,306 loops=1)

  • Merge Cond: (uracl.registry_id = tf.registry_id)
  • Join Filter: (((uracl.form_type_id IS NULL) OR (uracl.form_type_id = tf.form_type_id)) AND ((uracl.institute_id IS NULL) OR (uracl.institute_id = tf.institute_id)) AND ((uracl.physician_id IS NULL) OR (uracl.physician_id = tf.physician_id)) AND (((tf.target_approval_level = 0) AND (uracl.user_id = tf.owner_id)) OR (('frm_approve_'::text || (tf.target_approval_level)::text) = ANY (uracl.permissions))))
  • Rows Removed by Join Filter: 2,693,058
10. 0.211 2,008.298 ↑ 2,125.6 96 1

Sort (cost=106,358.77..106,868.92 rows=204,058 width=130) (actual time=2,008.231..2,008.298 rows=96 loops=1)

  • Sort Key: uracl.registry_id
  • Sort Method: quicksort Memory: 50kB
11. 0.081 2,008.087 ↑ 2,125.6 96 1

Subquery Scan on uracl (cost=22.75..74,411.26 rows=204,058 width=130) (actual time=1,950.493..2,008.087 rows=96 loops=1)

12. 5.766 2,008.006 ↑ 2,125.6 96 1

Nested Loop (cost=22.75..72,370.68 rows=204,058 width=214) (actual time=1,950.490..2,008.006 rows=96 loops=1)

13. 0.210 0.210 ↑ 1.0 514 1

Seq Scan on users (cost=0.00..19.14 rows=514 width=34) (actual time=0.011..0.210 rows=514 loops=1)

14. 6.682 2,002.030 ↓ 0.0 0 514

Hash Join (cost=22.75..60.25 rows=397 width=68) (actual time=3.892..3.895 rows=0 loops=514)

  • Hash Cond: (racl.trustee_id = trustee_id.trustee_id)
15. 1,981.984 1,981.984 ↑ 1.0 96 514

Seq Scan on registry_acl racl (cost=0.00..21.29 rows=96 width=84) (actual time=3.835..3.856 rows=96 loops=514)

  • Filter: (registry_id = 'ce0f4190-a4dc-4a76-a4c8-a993d44cef90'::uuid)
  • Rows Removed by Filter: 567
16. 0.514 13.364 ↑ 1,000.0 1 514

Hash (cost=10.25..10.25 rows=1,000 width=16) (actual time=0.026..0.026 rows=1 loops=514)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
17. 12.850 12.850 ↑ 1,000.0 1 514

Function Scan on get_trustee_list trustee_id (cost=0.25..10.25 rows=1,000 width=16) (actual time=0.025..0.025 rows=1 loops=514)

18. 445.001 632.803 ↓ 162.9 2,726,209 1

Sort (cost=16,377.00..16,418.83 rows=16,735 width=124) (actual time=214.232..632.803 rows=2,726,209 loops=1)

  • Sort Key: tf.registry_id
  • Sort Method: external sort Disk: 3,960kB
19. 4.247 187.802 ↓ 1.7 28,399 1

Subquery Scan on tf (cost=461.88..15,202.99 rows=16,735 width=124) (actual time=5.755..187.802 rows=28,399 loops=1)

20. 132.465 183.555 ↓ 1.7 28,399 1

Hash Join (cost=461.88..15,035.64 rows=16,735 width=124) (actual time=5.752..183.555 rows=28,399 loops=1)

  • Hash Cond: (f.attendance_period_id = ap.id)
21. 46.667 46.667 ↑ 1.0 40,138 1

Seq Scan on forms f (cost=0.00..10,009.38 rows=40,138 width=178) (actual time=0.421..46.667 rows=40,138 loops=1)

22. 0.753 4.423 ↑ 1.0 2,743 1

Hash (cost=427.60..427.60 rows=2,743 width=64) (actual time=4.423..4.423 rows=2,743 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 290kB
23. 1.762 3.670 ↑ 1.0 2,743 1

Hash Join (cost=220.53..427.60 rows=2,743 width=64) (actual time=0.881..3.670 rows=2,743 loops=1)

  • Hash Cond: (ap.attendance_id = a.id)
24. 1.057 1.057 ↑ 1.0 6,579 1

Seq Scan on attendance_periods ap (cost=0.00..189.79 rows=6,579 width=48) (actual time=0.006..1.057 rows=6,579 loops=1)

25. 0.317 0.851 ↑ 1.0 2,743 1

Hash (cost=186.24..186.24 rows=2,743 width=32) (actual time=0.851..0.851 rows=2,743 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 204kB
26. 0.534 0.534 ↑ 1.0 2,743 1

Seq Scan on attendances a (cost=0.00..186.24 rows=2,743 width=32) (actual time=0.013..0.534 rows=2,743 loops=1)

  • Filter: (registry_id = 'ce0f4190-a4dc-4a76-a4c8-a993d44cef90'::uuid)
  • Rows Removed by Filter: 3,836
27. 61.248 66.612 ↑ 3.2 36 33,306

Materialize (cost=450.54..453.47 rows=117 width=64) (actual time=0.000..0.002 rows=36 loops=33,306)

28. 0.007 5.364 ↑ 3.2 36 1

Subquery Scan on i (cost=450.54..452.88 rows=117 width=64) (actual time=5.348..5.364 rows=36 loops=1)

29. 0.687 5.357 ↑ 3.2 36 1

HashAggregate (cost=450.54..451.71 rows=117 width=528) (actual time=5.345..5.357 rows=36 loops=1)

  • Group Key: i_1.id
30. 0.727 4.670 ↑ 1.0 2,743 1

Hash Join (cost=229.16..443.68 rows=2,743 width=64) (actual time=0.813..4.670 rows=2,743 loops=1)

  • Hash Cond: (ap_1.institute_id = i_1.id)
31. 1.990 3.904 ↑ 1.0 2,743 1

Hash Join (cost=220.53..427.60 rows=2,743 width=16) (actual time=0.766..3.904 rows=2,743 loops=1)

  • Hash Cond: (ap_1.attendance_id = a_1.id)
32. 1.165 1.165 ↑ 1.0 6,579 1

Seq Scan on attendance_periods ap_1 (cost=0.00..189.79 rows=6,579 width=32) (actual time=0.004..1.165 rows=6,579 loops=1)

33. 0.268 0.749 ↑ 1.0 2,743 1

Hash (cost=186.24..186.24 rows=2,743 width=16) (actual time=0.749..0.749 rows=2,743 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 161kB
34. 0.481 0.481 ↑ 1.0 2,743 1

Seq Scan on attendances a_1 (cost=0.00..186.24 rows=2,743 width=16) (actual time=0.020..0.481 rows=2,743 loops=1)

  • Filter: (registry_id = 'ce0f4190-a4dc-4a76-a4c8-a993d44cef90'::uuid)
  • Rows Removed by Filter: 3,836
35. 0.016 0.039 ↑ 1.0 117 1

Hash (cost=7.17..7.17 rows=117 width=64) (actual time=0.039..0.039 rows=117 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 20kB
36. 0.023 0.023 ↑ 1.0 117 1

Seq Scan on institutes i_1 (cost=0.00..7.17 rows=117 width=64) (actual time=0.008..0.023 rows=117 loops=1)

Planning time : 1.957 ms
Execution time : 12,256.630 ms