explain.depesz.com

PostgreSQL's explain analyze made readable

Result: qVfa

Settings
# exclusive inclusive rows x rows loops node
1. 2.920 620.123 ↓ 292.0 292 1

Group (cost=20,282.24..20,285.44 rows=1 width=293) (actual time=603.517..620.123 rows=292 loops=1)

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

CTE domain_user_with_flowdown_rgs

3. 0.776 596.312 ↓ 146.0 584 1

HashAggregate (cost=20,257.12..20,257.16 rows=4 width=1,330) (actual time=596.063..596.312 rows=584 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. 0.247 595.536 ↓ 146.0 584 1

Append (cost=75.62..20,257.03 rows=4 width=1,330) (actual time=232.557..595.536 rows=584 loops=1)

5. 0.283 281.597 ↓ 146.0 292 1

Nested Loop Left Join (cost=75.62..14,263.67 rows=2 width=311) (actual time=232.556..281.597 rows=292 loops=1)

6. 0.181 281.314 ↓ 146.0 292 1

Nested Loop Left Join (cost=75.48..14,263.37 rows=2 width=37) (actual time=232.550..281.314 rows=292 loops=1)

7. 4.912 279.381 ↓ 146.0 292 1

Nested Loop (cost=75.21..14,262.72 rows=2 width=24) (actual time=232.535..279.381 rows=292 loops=1)

8. 9.120 24.629 ↓ 11.5 24,984 1

Nested Loop (cost=74.79..12,090.04 rows=2,167 width=24) (actual time=2.778..24.629 rows=24,984 loops=1)

9. 0.137 0.137 ↓ 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.137 rows=2 loops=1)

  • Filter: ((entity_type_id = 15) AND (client_id = 1,002))
  • Rows Removed by Filter: 226
10. 12.174 15.372 ↓ 3.4 12,492 2

Bitmap Heap Scan on domain_user du_1 (cost=74.65..12,036.10 rows=3,657 width=16) (actual time=1.381..7.686 rows=12,492 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,161
11. 1.362 1.362 ↓ 2.3 15,792 2

Bitmap Index Scan on idx_domain_user_3 (cost=0.00..73.73 rows=6,988 width=0) (actual time=0.681..0.681 rows=15,792 loops=2)

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

SubPlan (for Bitmap Heap Scan)

13. 0.918 1.836 ↓ 0.0 0 918

ProjectSet (cost=0.00..1.61 rows=100 width=4) (actual time=0.002..0.002 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. 249.840 249.840 ↓ 0.0 0 24,984

Index Scan using pk_child_sla on child_sla csla_1 (cost=0.41..1.00 rows=1 width=4) (actual time=0.010..0.010 rows=0 loops=24,984)

  • Index Cond: (id = du_1.entity_id)
  • Filter: ((NOT deleted) 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
16. 1.752 1.752 ↑ 1.0 1 292

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=292)

  • Index Cond: (du_1.user_id = id)
17. 0.000 0.000 ↓ 0.0 0 292

Index Scan using pk_user_group on user_group ug_3 (cost=0.13..0.15 rows=1 width=278) (actual time=0.000..0.000 rows=0 loops=292)

  • Index Cond: (du_1.user_group_id = id)
18. 0.000 23.912 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,553.30..2,806.50 rows=1 width=311) (actual time=23.912..23.912 rows=0 loops=1)

19. 0.001 23.912 ↓ 0.0 0 1

Nested Loop Left Join (cost=1,553.17..2,806.34 rows=1 width=37) (actual time=23.912..23.912 rows=0 loops=1)

20. 0.004 23.911 ↓ 0.0 0 1

Merge Join (cost=1,552.90..2,806.02 rows=1 width=24) (actual time=23.911..23.911 rows=0 loops=1)

  • Merge Cond: (prg.id = crg.flowdown_rolegroup)
21. 0.004 23.871 ↑ 30.0 1 1

Nested Loop (cost=1,548.69..39,141.83 rows=30 width=20) (actual time=23.871..23.871 rows=1 loops=1)

  • Join Filter: (du_2.role_group_id = prg.id)
22. 0.012 0.012 ↑ 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.012..0.012 rows=1 loops=1)

  • Filter: (entity_type_id = 61)
  • Rows Removed by Filter: 1
23. 0.003 23.855 ↑ 409.0 1 1

Materialize (cost=1,548.54..39,027.86 rows=409 width=16) (actual time=23.855..23.855 rows=1 loops=1)

24. 0.006 23.852 ↑ 409.0 1 1

Nested Loop (cost=1,548.54..39,025.81 rows=409 width=16) (actual time=23.852..23.852 rows=1 loops=1)

25. 10.292 23.811 ↑ 158.0 1 1

Bitmap Heap Scan on child_sla et (cost=1,548.12..37,518.30 rows=158 width=8) (actual time=23.811..23.811 rows=1 loops=1)

  • Filter: ((NOT deleted) 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,010
  • Heap Blocks: exact=242
26. 13.519 13.519 ↓ 5.9 188,130 1

Bitmap Index Scan on idx_child_sla_deleted_client_id_slaid (cost=0.00..1,548.08 rows=31,630 width=0) (actual time=13.519..13.519 rows=188,130 loops=1)

  • Index Cond: (deleted = false)
27. 0.020 0.035 ↑ 3.0 1 1

Index Scan using idx_du_entity_id on domain_user du_2 (cost=0.42..9.51 rows=3 width=16) (actual time=0.035..0.035 rows=1 loops=1)

  • Index Cond: (entity_id = et.contract_id)
  • Filter: ((user_id = 1,044) OR (SubPlan 2))
  • Rows Removed by Filter: 5
28.          

SubPlan (for Index Scan)

29. 0.005 0.015 ↓ 0.0 0 5

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

30. 0.010 0.010 ↓ 0.0 0 5

Seq Scan on user_group ug_1 (cost=0.00..1.10 rows=1 width=32) (actual time=0.002..0.002 rows=0 loops=5)

  • Filter: (id = du_2.user_group_id)
  • Rows Removed by Filter: 8
31. 0.010 0.036 ↓ 2.0 2 1

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

  • Sort Key: crg.flowdown_rolegroup
  • Sort Method: quicksort Memory: 25kB
32. 0.007 0.026 ↓ 2.0 2 1

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

  • Recheck Cond: ((entity_type_id = 15) AND (client_id = 1,002))
  • Heap Blocks: exact=2
33. 0.003 0.019 ↓ 0.0 0 1

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

34. 0.007 0.007 ↑ 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.007..0.007 rows=9 loops=1)

  • Index Cond: (entity_type_id = 15)
35. 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)
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

Index Scan using pk_user_group on user_group ug_4 (cost=0.13..0.15 rows=1 width=278) (never executed)

  • Index Cond: (du_2.user_group_id = id)
38. 0.307 289.780 ↓ 292.0 292 1

Nested Loop Left Join (cost=1,553.30..3,186.81 rows=1 width=311) (actual time=22.815..289.780 rows=292 loops=1)

39. 0.179 289.473 ↓ 292.0 292 1

Nested Loop Left Join (cost=1,553.17..3,186.65 rows=1 width=37) (actual time=22.810..289.473 rows=292 loops=1)

40. 0.252 287.542 ↓ 292.0 292 1

Merge Join (cost=1,552.90..3,186.33 rows=1 width=24) (actual time=22.798..287.542 rows=292 loops=1)

  • Merge Cond: (prg_1.id = crg_1.flowdown_rolegroup)
41. 6.433 287.193 ↓ 12.7 292 1

Nested Loop (cost=1,548.69..39,117.29 rows=23 width=20) (actual time=22.769..287.193 rows=292 loops=1)

  • Join Filter: (du_3.role_group_id = prg_1.id)
  • Rows Removed by Join Filter: 37,928
42. 0.129 0.129 ↓ 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.007..0.129 rows=13 loops=1)

  • Filter: (entity_type_id = 1)
  • Rows Removed by Filter: 215
43. 5.960 280.631 ↓ 7.2 2,940 13

Materialize (cost=1,548.54..39,027.86 rows=409 width=16) (actual time=1.751..21.587 rows=2,940 loops=13)

44. 1.198 274.671 ↓ 7.2 2,940 1

Nested Loop (cost=1,548.54..39,025.81 rows=409 width=16) (actual time=22.757..274.671 rows=2,940 loops=1)

45. 246.705 260.041 ↓ 1.8 292 1

Bitmap Heap Scan on child_sla et_1 (cost=1,548.12..37,518.30 rows=158 width=8) (actual time=22.693..260.041 rows=292 loops=1)

  • Filter: ((NOT deleted) 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: 31,339
  • Heap Blocks: exact=24,658
46. 13.336 13.336 ↓ 5.9 188,130 1

Bitmap Index Scan on idx_child_sla_deleted_client_id_slaid (cost=0.00..1,548.08 rows=31,630 width=0) (actual time=13.336..13.336 rows=188,130 loops=1)

  • Index Cond: (deleted = false)
47. 7.940 13.432 ↓ 3.3 10 292

Index Scan using idx_du_entity_id on domain_user du_3 (cost=0.42..9.51 rows=3 width=16) (actual time=0.036..0.046 rows=10 loops=292)

  • Index Cond: (entity_id = et_1.relation_id)
  • Filter: ((user_id = 1,044) OR (SubPlan 3))
  • Rows Removed by Filter: 19
48.          

SubPlan (for Index Scan)

49. 0.000 5.492 ↓ 0.0 0 5,492

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

50. 5.492 5.492 ↓ 0.0 0 5,492

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=5,492)

  • Filter: (id = du_3.user_group_id)
  • Rows Removed by Filter: 8
51. 0.077 0.097 ↓ 293.0 293 1

Sort (cost=4.21..4.22 rows=1 width=16) (actual time=0.025..0.097 rows=293 loops=1)

  • Sort Key: crg_1.flowdown_rolegroup
  • Sort Method: quicksort Memory: 25kB
52. 0.006 0.020 ↓ 2.0 2 1

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

  • Recheck Cond: ((entity_type_id = 15) AND (client_id = 1,002))
  • Heap Blocks: exact=2
53. 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)

54. 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)
55. 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.006..0.007 rows=66 loops=1)

  • Index Cond: (client_id = 1,002)
56. 1.752 1.752 ↑ 1.0 1 292

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=292)

  • Index Cond: (du_3.user_id = id)
57. 0.000 0.000 ↓ 0.0 0 292

Index Scan using pk_user_group on user_group ug_5 (cost=0.13..0.15 rows=1 width=278) (actual time=0.000..0.000 rows=0 loops=292)

  • Index Cond: (du_3.user_group_id = id)
58. 0.253 603.479 ↓ 294.0 294 1

Sort (cost=25.08..25.08 rows=1 width=169) (actual time=603.421..603.479 rows=294 loops=1)

  • Sort Key: csla.id, r.name, ets.description, c.name, c.document_title
  • Sort Method: quicksort Memory: 111kB
59. 0.323 603.226 ↓ 294.0 294 1

Nested Loop (cost=4.71..25.07 rows=1 width=169) (actual time=596.167..603.226 rows=294 loops=1)

60. 0.267 602.609 ↓ 294.0 294 1

Nested Loop Left Join (cost=4.43..24.76 rows=1 width=151) (actual time=596.156..602.609 rows=294 loops=1)

61. 0.340 601.466 ↓ 292.0 292 1

Nested Loop Left Join (cost=4.01..23.62 rows=1 width=155) (actual time=596.142..601.466 rows=292 loops=1)

62. 0.334 600.834 ↓ 292.0 292 1

Nested Loop Left Join (cost=3.72..23.06 rows=1 width=109) (actual time=596.130..600.834 rows=292 loops=1)

63. 0.193 600.208 ↓ 292.0 292 1

Nested Loop (cost=3.44..22.74 rows=1 width=62) (actual time=596.118..600.208 rows=292 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)))
64. 0.435 599.139 ↓ 32.4 292 1

Nested Loop (cost=3.15..18.50 rows=9 width=70) (actual time=596.101..599.139 rows=292 loops=1)

65. 596.660 596.660 ↓ 292.0 292 1

CTE Scan on domain_user_with_flowdown_rgs du (cost=0.00..3.83 rows=1 width=8) (actual time=596.068..596.660 rows=292 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: 292
66.          

SubPlan (for CTE Scan)

67. 0.000 0.000 ↓ 0.0 0

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

68. 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)
69. 0.876 2.044 ↑ 9.0 1 292

Bitmap Heap Scan on child_sla csla (cost=3.15..14.57 rows=9 width=62) (actual time=0.007..0.007 rows=1 loops=292)

  • 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[])))
  • Heap Blocks: exact=343
70. 0.292 1.168 ↓ 0.0 0 292

BitmapOr (cost=3.15..3.15 rows=10 width=0) (actual time=0.004..0.004 rows=0 loops=292)

71. 0.584 0.584 ↑ 1.0 1 292

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

  • Index Cond: (du.entity_id = id)
72. 0.292 0.292 ↓ 0.0 0 292

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=292)

  • Index Cond: ((du.entity_id = slaid) AND (client_id = 1,002) AND (deleted = false))
73. 0.876 0.876 ↑ 1.0 1 292

Index Scan using pk_sla on sla (cost=0.29..0.41 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=292)

  • Index Cond: (id = csla.slaid)
  • Filter: (client_id = 1,002)
74. 0.292 0.292 ↑ 1.0 1 292

Index Scan using pk_relation on relation r (cost=0.28..0.32 rows=1 width=55) (actual time=0.001..0.001 rows=1 loops=292)

  • Index Cond: (id = csla.relation_id)
75. 0.292 0.292 ↑ 1.0 1 292

Index Scan using pk_contract on contract c (cost=0.29..0.56 rows=1 width=54) (actual time=0.001..0.001 rows=1 loops=292)

  • Index Cond: (id = csla.contract_id)
76. 0.876 0.876 ↑ 1.0 1 292

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.003..0.003 rows=1 loops=292)

  • Index Cond: ((entity_id = sla.id) AND (entity_type_id = 14))
  • Heap Fetches: 312
77. 0.294 0.294 ↑ 1.0 1 294

Index Scan using pk_work_flow_status on work_flow_status ets (cost=0.28..0.30 rows=1 width=22) (actual time=0.001..0.001 rows=1 loops=294)

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

SubPlan (for Group)

79. 0.584 13.724 ↑ 1.0 1 292

Aggregate (cost=2.91..2.92 rows=1 width=32) (actual time=0.047..0.047 rows=1 loops=292)

80. 0.876 13.140 ↓ 2.0 2 292

Nested Loop (cost=0.14..2.90 rows=1 width=1,310) (actual time=0.016..0.045 rows=2 loops=292)

81. 11.680 11.680 ↓ 2.0 2 292

CTE Scan on domain_user_with_flowdown_rgs du_4 (cost=0.00..0.09 rows=1 width=1,314) (actual time=0.013..0.040 rows=2 loops=292)

  • Filter: (entity_id = csla.id)
  • Rows Removed by Filter: 582
82. 0.584 0.584 ↑ 1.0 1 584

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

  • Index Cond: (id = du_4.role_group_id)
  • Filter: (entity_type_id = 15)
Planning time : 6.564 ms
Execution time : 620.733 ms