explain.depesz.com

PostgreSQL's explain analyze made readable

Result: huU4

Settings
# exclusive inclusive rows x rows loops node
1. 5.215 2,132.116 ↓ 296.0 296 1

Group (cost=16,018.98..16,031.93 rows=1 width=293) (actual time=1,181.359..2,132.116 rows=296 loops=1)

  • Group Key: csla.id, r.name, ets.description, c.name, c.document_title
2.          

CTE domain_user_with_flowdown_rgs

3. 58.652 723.531 ↓ 150.0 49,811 1

HashAggregate (cost=15,649.85..15,653.17 rows=332 width=1,330) (actual time=696.937..723.531 rows=49,811 loops=1)

  • Group Key: du_1.entity_id, du_1.role_group_id, du_1.user_group_id, du_1.user_id, rg.client_id, rg.entity_type_id, u.first_name, u.last_name, ug_3.name
4. 14.444 664.879 ↓ 150.0 49,811 1

Append (cost=75.51..15,642.38 rows=332 width=1,330) (actual time=2.790..664.879 rows=49,811 loops=1)

5. 51.949 341.917 ↓ 76.6 25,052 1

Nested Loop Left Join (cost=75.51..13,309.77 rows=327 width=311) (actual time=2.789..341.917 rows=25,052 loops=1)

  • Join Filter: (du_1.user_group_id = ug_3.id)
  • Rows Removed by Join Filter: 200,416
6. 15.047 264.916 ↓ 76.6 25,052 1

Nested Loop Left Join (cost=75.51..13,269.43 rows=327 width=37) (actual time=2.776..264.916 rows=25,052 loops=1)

7. 26.751 99.557 ↓ 76.6 25,052 1

Nested Loop (cost=75.23..13,163.30 rows=327 width=24) (actual time=2.765..99.557 rows=25,052 loops=1)

8. 7.673 22.702 ↓ 11.6 25,052 1

Nested Loop (cost=74.82..12,094.98 rows=2,168 width=24) (actual time=2.753..22.702 rows=25,052 loops=1)

9. 0.181 0.181 ↓ 2.0 2 1

Index Scan using pk_role_group on role_group rg (cost=0.14..17.37 rows=1 width=12) (actual time=0.020..0.181 rows=2 loops=1)

  • Filter: ((entity_type_id = 15) AND (client_id = 1,002))
  • Rows Removed by Filter: 226
10. 12.490 14.848 ↓ 3.4 12,526 2

Bitmap Heap Scan on domain_user du_1 (cost=74.67..12,041.02 rows=3,659 width=16) (actual time=1.369..7.424 rows=12,526 loops=2)

  • Recheck Cond: (role_group_id = rg.id)
  • Filter: ((NOT entity_deleted) AND ((user_id = 1,044) OR (SubPlan 1)))
  • Rows Removed by Filter: 3,300
  • Heap Blocks: exact=1,162
11. 1.440 1.440 ↓ 2.3 15,826 2

Bitmap Index Scan on idx_domain_user_3 (cost=0.00..73.76 rows=6,991 width=0) (actual time=0.720..0.720 rows=15,826 loops=2)

  • Index Cond: (role_group_id = rg.id)
12.          

SubPlan (for Bitmap Heap Scan)

13. 0.000 0.918 ↓ 0.0 0 918

ProjectSet (cost=0.00..1.61 rows=100 width=4) (actual time=0.001..0.001 rows=0 loops=918)

14. 0.918 0.918 ↓ 0.0 0 918

Seq Scan on user_group ug (cost=0.00..1.10 rows=1 width=32) (actual time=0.001..0.001 rows=0 loops=918)

  • Filter: (id = du_1.user_group_id)
  • Rows Removed by Filter: 8
15. 50.104 50.104 ↑ 1.0 1 25,052

Index Scan using pk_child_sla on child_sla csla_1 (cost=0.41..0.49 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=25,052)

  • Index Cond: (id = du_1.entity_id)
  • Filter: (NOT deleted)
16. 150.312 150.312 ↑ 1.0 1 25,052

Index Scan using pk_app_user on app_user u (cost=0.28..0.32 rows=1 width=17) (actual time=0.006..0.006 rows=1 loops=25,052)

  • Index Cond: (du_1.user_id = id)
17. 25.048 25.052 ↑ 1.0 8 25,052

Materialize (cost=0.00..1.12 rows=8 width=278) (actual time=0.000..0.001 rows=8 loops=25,052)

18. 0.004 0.004 ↑ 1.0 8 1

Seq Scan on user_group ug_3 (cost=0.00..1.08 rows=8 width=278) (actual time=0.002..0.004 rows=8 loops=1)

19. 0.001 0.082 ↓ 0.0 0 1

Nested Loop Left Join (cost=5.47..1,137.57 rows=3 width=311) (actual time=0.081..0.082 rows=0 loops=1)

  • Join Filter: (du_2.user_group_id = ug_4.id)
20. 0.001 0.081 ↓ 0.0 0 1

Nested Loop Left Join (cost=5.47..1,136.11 rows=3 width=37) (actual time=0.081..0.081 rows=0 loops=1)

21. 0.001 0.080 ↓ 0.0 0 1

Nested Loop (cost=5.20..1,135.15 rows=3 width=24) (actual time=0.080..0.080 rows=0 loops=1)

22. 0.004 0.079 ↓ 0.0 0 1

Merge Join (cost=4.78..873.00 rows=20 width=24) (actual time=0.079..0.079 rows=0 loops=1)

  • Merge Cond: (prg.id = crg.flowdown_rolegroup)
23. 0.005 0.034 ↑ 40,331.0 1 1

Nested Loop (cost=0.57..118,581.97 rows=40,331 width=20) (actual time=0.034..0.034 rows=1 loops=1)

24. 0.014 0.014 ↑ 16.0 1 1

Index Scan using pk_role_group on role_group prg (cost=0.14..16.83 rows=16 width=4) (actual time=0.014..0.014 rows=1 loops=1)

  • Filter: (entity_type_id = 61)
  • Rows Removed by Filter: 1
25. 0.015 0.015 ↑ 4,254.0 1 1

Index Scan using idx_domain_user_3 on domain_user du_2 (cost=0.42..7,367.78 rows=4,254 width=16) (actual time=0.015..0.015 rows=1 loops=1)

  • Index Cond: (role_group_id = prg.id)
  • Filter: ((user_id = 1,044) OR (SubPlan 2))
26.          

SubPlan (for Index Scan)

27. 0.000 0.000 ↓ 0.0 0

ProjectSet (cost=0.00..1.61 rows=100 width=4) (never executed)

28. 0.000 0.000 ↓ 0.0 0

Seq Scan on user_group ug_1 (cost=0.00..1.10 rows=1 width=32) (never executed)

  • Filter: (id = du_2.user_group_id)
29. 0.002 0.041 ↓ 2.0 2 1

Materialize (cost=4.21..4.22 rows=1 width=16) (actual time=0.040..0.041 rows=2 loops=1)

30. 0.009 0.039 ↓ 2.0 2 1

Sort (cost=4.21..4.22 rows=1 width=16) (actual time=0.038..0.039 rows=2 loops=1)

  • Sort Key: crg.flowdown_rolegroup
  • Sort Method: quicksort Memory: 25kB
31. 0.009 0.030 ↓ 2.0 2 1

Bitmap Heap Scan on role_group crg (cost=3.09..4.20 rows=1 width=16) (actual time=0.029..0.030 rows=2 loops=1)

  • Recheck Cond: ((entity_type_id = 15) AND (client_id = 1,002))
  • Heap Blocks: exact=2
32. 0.002 0.021 ↓ 0.0 0 1

BitmapAnd (cost=3.09..3.09 rows=1 width=0) (actual time=0.021..0.021 rows=0 loops=1)

33. 0.010 0.010 ↑ 1.0 9 1

Bitmap Index Scan on role_group_entity_type_id_idx (cost=0.00..1.31 rows=9 width=0) (actual time=0.009..0.010 rows=9 loops=1)

  • Index Cond: (entity_type_id = 15)
34. 0.009 0.009 ↓ 1.8 66 1

Bitmap Index Scan on idx_role_grp_client_id (cost=0.00..1.52 rows=37 width=0) (actual time=0.009..0.009 rows=66 loops=1)

  • Index Cond: (client_id = 1,002)
35. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_child_sla_4 on child_sla et (cost=0.41..9.15 rows=396 width=8) (never executed)

  • Index Cond: (contract_id = du_2.entity_id)
  • Filter: (NOT deleted)
36. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_app_user on app_user u_1 (cost=0.28..0.32 rows=1 width=17) (never executed)

  • Index Cond: (du_2.user_id = id)
37. 0.000 0.000 ↓ 0.0 0

Materialize (cost=0.00..1.12 rows=8 width=278) (never executed)

38. 0.000 0.000 ↓ 0.0 0

Seq Scan on user_group ug_4 (cost=0.00..1.08 rows=8 width=278) (never executed)

39. 50.919 308.436 ↓ 12,379.5 24,759 1

Nested Loop Left Join (cost=5.47..1,190.06 rows=2 width=311) (actual time=0.124..308.436 rows=24,759 loops=1)

  • Join Filter: (du_3.user_group_id = ug_5.id)
  • Rows Removed by Join Filter: 198,072
40. 13.334 232.758 ↓ 12,379.5 24,759 1

Nested Loop Left Join (cost=5.47..1,188.72 rows=2 width=37) (actual time=0.111..232.758 rows=24,759 loops=1)

41. 10.002 70.870 ↓ 12,379.5 24,759 1

Nested Loop (cost=5.20..1,188.08 rows=2 width=24) (actual time=0.099..70.870 rows=24,759 loops=1)

42. 2.356 14.068 ↓ 260.0 3,900 1

Merge Join (cost=4.78..675.65 rows=15 width=24) (actual time=0.046..14.068 rows=3,900 loops=1)

  • Merge Cond: (prg_1.id = crg_1.flowdown_rolegroup)
43. 1.362 11.037 ↑ 7.8 3,901 1

Nested Loop (cost=0.57..91,732.62 rows=30,248 width=20) (actual time=0.021..11.037 rows=3,901 loops=1)

44. 0.107 0.107 ↓ 1.1 13 1

Index Scan using pk_role_group on role_group prg_1 (cost=0.14..16.83 rows=12 width=4) (actual time=0.005..0.107 rows=13 loops=1)

  • Filter: (entity_type_id = 1)
  • Rows Removed by Filter: 205
45. 6.324 9.568 ↑ 14.2 300 13

Index Scan using idx_domain_user_3 on domain_user du_3 (cost=0.42..7,600.44 rows=4,254 width=16) (actual time=0.075..0.736 rows=300 loops=13)

  • Index Cond: (role_group_id = prg_1.id)
  • Filter: ((user_id = 1,044) OR (SubPlan 3))
  • Rows Removed by Filter: 125
46.          

SubPlan (for Index Scan)

47. 1.622 3.244 ↓ 0.0 0 1,622

ProjectSet (cost=0.00..1.61 rows=100 width=4) (actual time=0.002..0.002 rows=0 loops=1,622)

48. 1.622 1.622 ↓ 0.0 0 1,622

Seq Scan on user_group ug_2 (cost=0.00..1.10 rows=1 width=32) (actual time=0.001..0.001 rows=0 loops=1,622)

  • Filter: (id = du_3.user_group_id)
  • Rows Removed by Filter: 8
49. 0.653 0.675 ↓ 3,901.0 3,901 1

Materialize (cost=4.21..4.22 rows=1 width=16) (actual time=0.022..0.675 rows=3,901 loops=1)

50. 0.004 0.022 ↓ 2.0 2 1

Sort (cost=4.21..4.22 rows=1 width=16) (actual time=0.021..0.022 rows=2 loops=1)

  • Sort Key: crg_1.flowdown_rolegroup
  • Sort Method: quicksort Memory: 25kB
51. 0.004 0.018 ↓ 2.0 2 1

Bitmap Heap Scan on role_group crg_1 (cost=3.09..4.20 rows=1 width=16) (actual time=0.016..0.018 rows=2 loops=1)

  • Recheck Cond: ((entity_type_id = 15) AND (client_id = 1,002))
  • Heap Blocks: exact=2
52. 0.002 0.014 ↓ 0.0 0 1

BitmapAnd (cost=3.09..3.09 rows=1 width=0) (actual time=0.014..0.014 rows=0 loops=1)

53. 0.005 0.005 ↑ 1.0 9 1

Bitmap Index Scan on role_group_entity_type_id_idx (cost=0.00..1.31 rows=9 width=0) (actual time=0.005..0.005 rows=9 loops=1)

  • Index Cond: (entity_type_id = 15)
54. 0.007 0.007 ↓ 1.8 66 1

Bitmap Index Scan on idx_role_grp_client_id (cost=0.00..1.52 rows=37 width=0) (actual time=0.007..0.007 rows=66 loops=1)

  • Index Cond: (client_id = 1,002)
55. 46.800 46.800 ↑ 176.0 6 3,900

Index Scan using idx_child_sla_3 on child_sla et_1 (cost=0.41..23.60 rows=1,056 width=8) (actual time=0.001..0.012 rows=6 loops=3,900)

  • Index Cond: (relation_id = du_3.entity_id)
  • Filter: (NOT deleted)
  • Rows Removed by Filter: 1
56. 148.554 148.554 ↑ 1.0 1 24,759

Index Scan using pk_app_user on app_user u_2 (cost=0.28..0.32 rows=1 width=17) (actual time=0.006..0.006 rows=1 loops=24,759)

  • Index Cond: (du_3.user_id = id)
57. 24.753 24.759 ↑ 1.0 8 24,759

Materialize (cost=0.00..1.12 rows=8 width=278) (actual time=0.000..0.001 rows=8 loops=24,759)

58. 0.006 0.006 ↑ 1.0 8 1

Seq Scan on user_group ug_5 (cost=0.00..1.08 rows=8 width=278) (actual time=0.004..0.006 rows=8 loops=1)

59. 0.452 1,178.221 ↓ 302.0 302 1

Sort (cost=365.82..365.82 rows=1 width=169) (actual time=1,178.101..1,178.221 rows=302 loops=1)

  • Sort Key: csla.id, r.name, ets.description, c.name, c.document_title
  • Sort Method: quicksort Memory: 115kB
60. 0.379 1,177.769 ↓ 302.0 302 1

Nested Loop (cost=4.71..365.81 rows=1 width=169) (actual time=699.640..1,177.769 rows=302 loops=1)

61. 0.481 1,176.786 ↓ 302.0 302 1

Nested Loop Left Join (cost=4.43..364.83 rows=1 width=151) (actual time=699.629..1,176.786 rows=302 loops=1)

62. 0.607 1,174.825 ↓ 296.0 296 1

Nested Loop (cost=4.01..363.69 rows=1 width=155) (actual time=699.615..1,174.825 rows=296 loops=1)

  • Join Filter: (((du.entity_id = csla.id) AND (du.role_group_id = 2,003) AND (sla.status_id = ANY ('{1511,5,1502,1,1501,1508,1499,1497,1512,1504,6,1500,1510,1509,1496,2,1513,1514,1498,1506,1503,1507,1505,1618,1616,1614,1612,1615,1611,1613,1617}'::integer[]))) OR ((du.entity_id = sla.id) AND (du.role_group_id = 2,002)))
  • Rows Removed by Join Filter: 288
63. 0.789 1,170.714 ↓ 584.0 584 1

Nested Loop Left Join (cost=3.72..361.64 rows=1 width=163) (actual time=697.734..1,170.714 rows=584 loops=1)

64. 1.000 1,168.757 ↓ 584.0 584 1

Nested Loop Left Join (cost=3.43..359.29 rows=1 width=117) (actual time=697.719..1,168.757 rows=584 loops=1)

65. 9.764 1,166.589 ↓ 584.0 584 1

Nested Loop (cost=3.15..357.66 rows=1 width=70) (actual time=697.707..1,166.589 rows=584 loops=1)

66. 755.993 755.993 ↓ 12,526.0 25,052 1

CTE Scan on domain_user_with_flowdown_rgs du (cost=0.00..318.30 rows=2 width=8) (actual time=696.946..755.993 rows=25,052 loops=1)

  • Filter: (((role_group_id = 2,003) OR (role_group_id = 2,002)) AND ((user_id = 1,044) OR (SubPlan 6)))
  • Rows Removed by Filter: 24,759
67.          

SubPlan (for CTE Scan)

68. 0.000 0.000 ↓ 0.0 0

ProjectSet (cost=0.00..1.61 rows=100 width=4) (never executed)

69. 0.000 0.000 ↓ 0.0 0

Seq Scan on user_group ug_6 (cost=0.00..1.10 rows=1 width=32) (never executed)

  • Filter: (id = du.user_group_id)
70. 275.572 400.832 ↓ 0.0 0 25,052

Bitmap Heap Scan on child_sla csla (cost=3.15..19.67 rows=1 width=62) (actual time=0.015..0.016 rows=0 loops=25,052)

  • Recheck Cond: ((du.entity_id = id) OR ((du.entity_id = slaid) AND (client_id = 1,002) AND (NOT deleted)))
  • Filter: ((NOT deleted) AND (client_id = 1,002) AND (status_id = ANY ('{1628,1626,1621,1620,1622,1627,1623,1624,1625,1619,1568,1,1566,2,4,1567,1563,1564,1565,1562,21}'::integer[])) AND ((change_tz(reporting_date, 'UTC'::character varying, 'Asia/Kolkata'::character varying))::date >= '2020-07-24 00:00:00'::timestamp without time zone) AND ((change_tz(reporting_date, 'UTC'::character varying, 'Asia/Kolkata'::character varying))::date <= '2020-09-15 00:00:00'::timestamp without time zone))
  • Rows Removed by Filter: 1
  • Heap Blocks: exact=47,035
71. 50.104 125.260 ↓ 0.0 0 25,052

BitmapOr (cost=3.15..3.15 rows=10 width=0) (actual time=0.005..0.005 rows=0 loops=25,052)

72. 50.104 50.104 ↓ 2.0 2 25,052

Bitmap Index Scan on pk_child_sla (cost=0.00..1.52 rows=1 width=0) (actual time=0.002..0.002 rows=2 loops=25,052)

  • Index Cond: (du.entity_id = id)
73. 25.052 25.052 ↓ 0.0 0 25,052

Bitmap Index Scan on idx_child_sla_deleted_client_id_slaid (cost=0.00..1.63 rows=9 width=0) (actual time=0.001..0.001 rows=0 loops=25,052)

  • Index Cond: ((du.entity_id = slaid) AND (client_id = 1,002) AND (deleted = false))
74. 1.168 1.168 ↑ 1.0 1 584

Index Scan using pk_relation on relation r (cost=0.28..1.63 rows=1 width=55) (actual time=0.002..0.002 rows=1 loops=584)

  • Index Cond: (id = csla.relation_id)
75. 1.168 1.168 ↑ 1.0 1 584

Index Scan using pk_contract on contract c (cost=0.29..2.35 rows=1 width=54) (actual time=0.002..0.002 rows=1 loops=584)

  • Index Cond: (id = csla.contract_id)
76. 3.504 3.504 ↑ 1.0 1 584

Index Scan using pk_sla on sla (cost=0.29..1.98 rows=1 width=8) (actual time=0.004..0.006 rows=1 loops=584)

  • Index Cond: (id = csla.slaid)
  • Filter: (client_id = 1,002)
77. 1.480 1.480 ↑ 1.0 1 296

Index Only Scan using idx_link_entity_function_6 on link_entity_function lef (cost=0.42..1.13 rows=1 width=4) (actual time=0.005..0.005 rows=1 loops=296)

  • Index Cond: ((entity_id = sla.id) AND (entity_type_id = 14))
  • Heap Fetches: 320
78. 0.604 0.604 ↑ 1.0 1 302

Index Scan using pk_work_flow_status on work_flow_status ets (cost=0.28..0.98 rows=1 width=22) (actual time=0.002..0.002 rows=1 loops=302)

  • Index Cond: (id = csla.status_id)
79.          

SubPlan (for Group)

80. 0.888 948.680 ↑ 1.0 1 296

Aggregate (cost=12.66..12.67 rows=1 width=32) (actual time=3.205..3.205 rows=1 loops=296)

81. 0.888 947.792 ↓ 2.0 2 296

Nested Loop (cost=0.14..12.64 rows=1 width=1,310) (actual time=1.062..3.202 rows=2 loops=296)

82. 945.128 945.128 ↑ 1.0 2 296

CTE Scan on domain_user_with_flowdown_rgs du_4 (cost=0.00..7.47 rows=2 width=1,314) (actual time=1.057..3.193 rows=2 loops=296)

  • Filter: (entity_id = csla.id)
  • Rows Removed by Filter: 49,809
83. 1.776 1.776 ↑ 1.0 1 592

Index Scan using pk_role_group on role_group rg_1 (cost=0.14..2.37 rows=1 width=4) (actual time=0.003..0.003 rows=1 loops=592)

  • Index Cond: (id = du_4.role_group_id)
  • Filter: (entity_type_id = 15)
Planning time : 7.608 ms
Execution time : 2,133.804 ms