explain.depesz.com

PostgreSQL's explain analyze made readable

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

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 868.652 12,797.780 ↑ 2,262,607.0 1,040 1

GroupAggregate (cost=4,126,026,771.16..4,462,774,779.08 rows=2,353,111,263 width=186) (actual time=11,498.824..12,797.780 rows=1,040 loops=1)

  • Group Key: ufc.institute_name, ufc.user_name
  • Group Key: ufc.institute_name
  • Functions: 93
  • Options: Inlining true, Optimization true, Expressions true, Deforming true
  • Timing: Generation 12.612 ms, Inlining 42.674 ms, Optimization 796.025 ms, Emission 511.945 ms, Total 1363.255 ms
2. 3,128.916 11,929.128 ↑ 2,011.7 1,197,701 1

Sort (cost=4,126,026,771.16..4,132,050,172.99 rows=2,409,360,733 width=126) (actual time=11,498.795..11,929.128 rows=1,197,701 loops=1)

  • Sort Key: ufc.institute_name, ufc.user_name
  • Sort Method: external merge Disk: 255,088kB
3. 91.775 8,800.212 ↑ 2,011.7 1,197,701 1

Subquery Scan on ufc (cost=2,829,701,426.64..2,968,239,668.79 rows=2,409,360,733 width=126) (actual time=7,594.286..8,800.212 rows=1,197,701 loops=1)

4. 873.835 8,708.437 ↑ 2,011.7 1,197,701 1

WindowAgg (cost=2,829,701,426.64..2,944,146,061.46 rows=2,409,360,733 width=170) (actual time=7,594.283..8,708.437 rows=1,197,701 loops=1)

5. 1,599.300 7,834.602 ↑ 2,011.7 1,197,701 1

Sort (cost=2,829,701,426.64..2,835,724,828.48 rows=2,409,360,733 width=150) (actual time=7,593.626..7,834.602 rows=1,197,701 loops=1)

  • Sort Key: tf.attendance_id, tf.target_approval_level
  • Sort Method: external merge Disk: 288,048kB
6. 693.851 6,235.302 ↑ 2,011.7 1,197,701 1

WindowAgg (cost=1,494,176,912.78..1,548,387,529.27 rows=2,409,360,733 width=150) (actual time=5,135.283..6,235.302 rows=1,197,701 loops=1)

7. 2,176.670 5,541.451 ↑ 2,011.7 1,197,701 1

Sort (cost=1,494,176,912.78..1,500,200,314.61 rows=2,409,360,733 width=142) (actual time=5,134.972..5,541.451 rows=1,197,701 loops=1)

  • Sort Key: tf.attendance_id, users.name, tf.target_approval_level
  • Sort Method: external merge Disk: 278,664kB
8. 165.128 3,364.781 ↑ 2,011.7 1,197,701 1

Nested Loop (cost=15,885.72..254,038,607.91 rows=2,409,360,733 width=142) (actual time=1,508.558..3,364.781 rows=1,197,701 loops=1)

  • Join Filter: ((racl.institute_id = i.id) OR (racl.institute_id IS NULL))
  • Rows Removed by Join Filter: 223,831
9. 474.942 3,120.679 ↑ 1,546.9 39,487 1

Hash Left Join (cost=15,435.17..146,838,574.33 rows=61,082,382 width=110) (actual time=1,505.310..3,120.679 rows=39,487 loops=1)

  • Hash Cond: (racl.registry_id = tf.registry_id)
  • Join Filter: (((racl.form_type_id IS NULL) OR (racl.form_type_id = tf.form_type_id)) AND ((racl.institute_id IS NULL) OR (racl.institute_id = tf.institute_id)) AND ((racl.physician_id IS NULL) OR (racl.physician_id = tf.physician_id)) AND (((tf.target_approval_level = ANY ('{0,5}'::integer[])) AND (users.id = tf.owner_id)) OR (('frm_approve_'::text || (tf.target_approval_level)::text) = ANY (permissions.permissions))))
  • Rows Removed by Join Filter: 2,686,870
10. 3.297 2,500.715 ↑ 2,124.0 96 1

Nested Loop (cost=23.00..22,343.32 rows=203,901 width=130) (actual time=1,359.846..2,500.715 rows=96 loops=1)

11. 0.406 0.406 ↑ 1.0 514 1

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

12. 22.102 2,497.012 ↓ 0.0 0 514

Hash Join (cost=23.00..62.42 rows=397 width=96) (actual time=4.720..4.858 rows=0 loops=514)

  • Hash Cond: (racl.trustee_id = trustee_id.trustee_id)
13. 54.484 2,446.640 ↑ 1.0 96 514

Nested Loop (cost=0.25..23.46 rows=96 width=112) (actual time=2.721..4.760 rows=96 loops=514)

14. 1,405.276 1,405.276 ↑ 1.0 96 514

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

  • Filter: (registry_id = 'ce0f4190-a4dc-4a76-a4c8-a993d44cef90'::uuid)
  • Rows Removed by Filter: 567
15. 986.880 986.880 ↑ 1.0 1 49,344

Function Scan on to_registry_perm_flags permissions (cost=0.25..0.26 rows=1 width=32) (actual time=0.020..0.020 rows=1 loops=49,344)

16. 1.542 28.270 ↑ 1,000.0 1 514

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
17. 26.728 26.728 ↑ 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.051..0.052 rows=1 loops=514)

18. 8.400 145.022 ↓ 1.7 28,399 1

Hash (cost=15,202.99..15,202.99 rows=16,735 width=124) (actual time=145.022..145.022 rows=28,399 loops=1)

  • Buckets: 32,768 (originally 32768) Batches: 2 (originally 1) Memory Usage: 4,694kB
19. 2.879 136.622 ↓ 1.7 28,399 1

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

20. 94.333 133.743 ↓ 1.7 28,399 1

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

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

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

22. 0.915 6.008 ↑ 1.0 2,743 1

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

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

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

  • Hash Cond: (ap.attendance_id = a.id)
24. 1.322 1.322 ↑ 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.322 rows=6,579 loops=1)

25. 0.533 1.584 ↑ 1.0 2,743 1

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

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

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

  • Filter: (registry_id = 'ce0f4190-a4dc-4a76-a4c8-a993d44cef90'::uuid)
  • Rows Removed by Filter: 3,836
27. 75.738 78.974 ↑ 3.2 36 39,487

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

28. 0.004 3.236 ↑ 3.2 36 1

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

29. 0.320 3.232 ↑ 3.2 36 1

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

  • Group Key: i_1.id
30. 0.390 2.912 ↑ 1.0 2,743 1

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

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

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

  • Hash Cond: (ap_1.attendance_id = a_1.id)
32. 0.631 0.631 ↑ 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..0.631 rows=6,579 loops=1)

33. 0.352 0.960 ↑ 1.0 2,743 1

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

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

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

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

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

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

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

Execution time : 12,904.410 ms