explain.depesz.com

PostgreSQL's explain analyze made readable

Result: BV6X

Settings
# exclusive inclusive rows x rows loops node
1. 9.086 3,640.775 ↓ 292.0 292 1

Group (cost=20,280.31..20,287.19 rows=1 width=293) (actual time=607.592..3,640.775 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.757 583.192 ↓ 146.0 584 1

HashAggregate (cost=20,255.19..20,255.23 rows=4 width=24) (actual time=582.859..583.192 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
4. 0.215 582.435 ↓ 146.0 584 1

Append (cost=75.21..20,255.13 rows=4 width=24) (actual time=231.428..582.435 rows=584 loops=1)

5. 2.164 277.262 ↓ 146.0 292 1

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

6. 9.038 25.258 ↓ 11.5 24,984 1

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

7. 0.146 0.146 ↓ 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.028..0.146 rows=2 loops=1)

  • Filter: ((entity_type_id = 15) AND (client_id = 1,002))
  • Rows Removed by Filter: 226
8. 12.814 16.074 ↓ 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.425..8.037 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
9. 1.424 1.424 ↓ 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.712..0.712 rows=15,792 loops=2)

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

SubPlan (for Bitmap Heap Scan)

11. 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)

12. 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
13. 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
14. 0.004 23.108 ↓ 0.0 0 1

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

  • Merge Cond: (prg.id = crg.flowdown_rolegroup)
15. 0.002 23.073 ↑ 30.0 1 1

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

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

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

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

18. 0.003 23.056 ↑ 409.0 1 1

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

19. 9.532 23.020 ↑ 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.020..23.020 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
20. 13.488 13.488 ↓ 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.488..13.488 rows=188,130 loops=1)

  • Index Cond: (deleted = false)
21. 0.018 0.033 ↑ 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.033..0.033 rows=1 loops=1)

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

SubPlan (for Index Scan)

23. 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)

24. 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
25. 0.007 0.031 ↓ 2.0 2 1

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

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

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

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

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

28. 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)
29. 0.008 0.008 ↓ 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.008..0.008 rows=66 loops=1)

  • Index Cond: (client_id = 1,002)
30. 0.258 281.850 ↓ 292.0 292 1

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

  • Merge Cond: (prg_1.id = crg_1.flowdown_rolegroup)
31. 6.976 281.480 ↓ 12.7 292 1

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

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

  • Filter: (entity_type_id = 1)
  • Rows Removed by Filter: 215
33. 6.507 274.365 ↓ 7.2 2,940 13

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

34. 1.207 267.858 ↓ 7.2 2,940 1

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

35. 240.553 253.511 ↓ 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.428..253.511 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
36. 12.958 12.958 ↓ 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=12.958..12.958 rows=188,130 loops=1)

  • Index Cond: (deleted = false)
37. 7.648 13.140 ↓ 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.045 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
38.          

SubPlan (for Index Scan)

39. 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)

40. 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
41. 0.086 0.112 ↓ 293.0 293 1

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

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

Bitmap Heap Scan on role_group crg_1 (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
43. 0.002 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)

44. 0.008 0.008 ↑ 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.008..0.008 rows=9 loops=1)

  • Index Cond: (entity_type_id = 15)
45. 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)
46. 0.429 596.933 ↓ 294.0 294 1

Sort (cost=25.08..25.08 rows=1 width=169) (actual time=596.752..596.933 rows=294 loops=1)

  • Sort Key: csla.id, r.name, ets.description, c.name, c.document_title
  • Sort Method: quicksort Memory: 111kB
47. 0.543 596.504 ↓ 294.0 294 1

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

48. 0.160 595.373 ↓ 294.0 294 1

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

49. 0.427 593.753 ↓ 292.0 292 1

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

50. 0.223 592.450 ↓ 292.0 292 1

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

51. 0.545 591.351 ↓ 292.0 292 1

Nested Loop (cost=3.44..22.74 rows=1 width=62) (actual time=582.914..591.351 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)))
52. 0.661 587.302 ↓ 32.4 292 1

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

53. 583.721 583.721 ↓ 292.0 292 1

CTE Scan on domain_user_with_flowdown_rgs du (cost=0.00..3.83 rows=1 width=8) (actual time=582.866..583.721 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
54.          

SubPlan (for CTE Scan)

55. 0.000 0.000 ↓ 0.0 0

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

56. 0.000 0.000 ↓ 0.0 0

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

  • Filter: (id = du.user_group_id)
57. 1.168 2.920 ↑ 9.0 1 292

Bitmap Heap Scan on child_sla csla (cost=3.15..14.57 rows=9 width=62) (actual time=0.009..0.010 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
58. 0.584 1.752 ↓ 0.0 0 292

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

59. 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)
60. 0.584 0.584 ↓ 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.002..0.002 rows=0 loops=292)

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

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

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

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

  • Index Cond: (id = csla.relation_id)
63. 0.876 0.876 ↑ 1.0 1 292

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

  • Index Cond: (id = csla.contract_id)
64. 1.460 1.460 ↑ 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.004..0.005 rows=1 loops=292)

  • Index Cond: ((entity_id = sla.id) AND (entity_type_id = 14))
  • Heap Fetches: 312
65. 0.588 0.588 ↑ 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.002..0.002 rows=1 loops=294)

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

SubPlan (for Group)

67. 1.752 3,034.756 ↑ 1.0 1 292

Aggregate (cost=6.59..6.60 rows=1 width=32) (actual time=10.393..10.393 rows=1 loops=292)

68. 2.044 3,033.004 ↓ 2.0 2 292

Nested Loop Left Join (cost=1.53..6.58 rows=1 width=291) (actual time=5.169..10.387 rows=2 loops=292)

  • Join Filter: (du_4.user_group_id = ug_3.id)
  • Rows Removed by Join Filter: 16
69. 1.752 3,029.208 ↓ 2.0 2 292

Nested Loop Left Join (cost=1.53..5.40 rows=1 width=21) (actual time=5.162..10.374 rows=2 loops=292)

70. 1.168 16.352 ↓ 2.0 2 292

Nested Loop (cost=0.14..2.90 rows=1 width=8) (actual time=0.021..0.056 rows=2 loops=292)

71. 12.848 12.848 ↓ 2.0 2 292

CTE Scan on domain_user_with_flowdown_rgs du_4 (cost=0.00..0.09 rows=1 width=12) (actual time=0.014..0.044 rows=2 loops=292)

  • Filter: (entity_id = csla.id)
  • Rows Removed by Filter: 582
72. 2.336 2.336 ↑ 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.004..0.004 rows=1 loops=584)

  • Index Cond: (id = du_4.role_group_id)
  • Filter: (entity_type_id = 15)
73. 2,672.968 3,011.104 ↑ 1.0 1 584

Bitmap Heap Scan on app_user u (cost=1.38..2.50 rows=1 width=17) (actual time=5.156..5.156 rows=1 loops=584)

  • Recheck Cond: (du_4.user_id = id)
  • Heap Blocks: exact=2,952,120
74. 338.136 338.136 ↓ 5,059.0 5,059 584

Bitmap Index Scan on pk_app_user (cost=0.00..1.38 rows=1 width=0) (actual time=0.579..0.579 rows=5,059 loops=584)

  • Index Cond: (du_4.user_id = id)
75. 1.752 1.752 ↑ 1.0 8 584

Seq Scan on user_group ug_3 (cost=0.00..1.08 rows=8 width=278) (actual time=0.001..0.003 rows=8 loops=584)

Planning time : 5.547 ms
Execution time : 3,641.409 ms