explain.depesz.com

PostgreSQL's explain analyze made readable

Result: f1Kl

Settings
# exclusive inclusive rows x rows loops node
1. 1.510 3,535.267 ↓ 318.6 4,142 1

Subquery Scan on all_data (cost=76,524.32..76,528.03 rows=13 width=242) (actual time=3,505.479..3,535.267 rows=4,142 loops=1)

2.          

CTE domain_user_with_flowdown_rgs

3. 8.008 3,427.660 ↓ 199.7 4,394 1

HashAggregate (cost=76,516.72..76,516.94 rows=22 width=1,330) (actual time=3,425.476..3,427.660 rows=4,394 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_2.name
4. 1.898 3,419.652 ↓ 199.7 4,394 1

Append (cost=75.61..76,516.22 rows=22 width=1,330) (actual time=5.932..3,419.652 rows=4,394 loops=1)

5. 6.458 2,448.704 ↓ 295.2 4,133 1

Nested Loop Left Join (cost=75.61..44,754.25 rows=14 width=311) (actual time=5.931..2,448.704 rows=4,133 loops=1)

6. 5.168 2,442.246 ↓ 295.2 4,133 1

Nested Loop Left Join (cost=75.48..44,752.14 rows=14 width=37) (actual time=5.925..2,442.246 rows=4,133 loops=1)

7. 29.646 730.149 ↓ 295.2 4,133 1

Nested Loop (cost=75.20..44,747.68 rows=14 width=24) (actual time=5.019..730.149 rows=4,133 loops=1)

8. 11.655 43.923 ↓ 4.3 32,829 1

Nested Loop (cost=74.91..30,782.30 rows=7,555 width=24) (actual time=2.406..43.923 rows=32,829 loops=1)

9. 0.214 0.214 ↑ 1.5 2 1

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

  • Filter: ((entity_type_id = 61) AND (client_id = 1,002))
  • Rows Removed by Filter: 226
10. 23.550 32.054 ↓ 3.9 16,414 2

Bitmap Heap Scan on domain_user du_1 (cost=74.77..10,212.49 rows=4,249 width=16) (actual time=1.197..16.027 rows=16,414 loops=2)

  • Recheck Cond: (role_group_id = rg.id)
  • Filter: ((user_id = 1,044) OR (SubPlan 1))
  • Rows Removed by Filter: 1,622
  • Heap Blocks: exact=2,873
11. 2.018 2.018 ↓ 2.6 18,062 2

Bitmap Index Scan on idx_domain_user_3 (cost=0.00..73.70 rows=6,984 width=0) (actual time=1.008..1.009 rows=18,062 loops=2)

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

SubPlan (for Bitmap Heap Scan)

13. 3.243 6.486 ↓ 0.0 0 3,243

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

14. 3.243 3.243 ↓ 0.0 0 3,243

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

  • Filter: (id = du_1.user_group_id)
  • Rows Removed by Filter: 8
15. 656.580 656.580 ↓ 0.0 0 32,829

Index Scan using pk_contract on contract c_1 (cost=0.29..1.85 rows=1 width=4) (actual time=0.020..0.020 rows=0 loops=32,829)

  • Index Cond: (id = du_1.entity_id)
  • Filter: ((NOT deleted) AND ((((change_tz(exp_date, 'UTC'::character varying, 'IST'::character varying))::date >= '2020-07-24 00:00:00'::timestamp without time zone) AND ((change_tz(exp_date, 'UTC'::character varying, 'IST'::character varying))::date <= '2020-09-15 00:00:00'::timestamp without time zone)) OR (((change_tz(notice_lead_date, 'UTC'::character varying, 'IST'::character varying))::date >= '2020-07-24 00:00:00'::timestamp without time zone) AND ((change_tz(notice_lead_date, 'UTC'::character varying, 'IST'::character varying))::date <= '2020-09-15 00:00:00'::timestamp without time zone)) OR (((change_tz(notice_date, 'UTC'::character varying, 'IST'::character varying))::date >= '2020-07-24 00:00:00'::timestamp without time zone) AND ((change_tz(notice_date, 'UTC'::character varying, 'IST'::character varying))::date <= '2020-09-15 00:00:00'::timestamp without time zone))))
  • Rows Removed by Filter: 1
16. 1,706.929 1,706.929 ↑ 1.0 1 4,133

Index Scan using pk_app_user on app_user u (cost=0.28..0.32 rows=1 width=17) (actual time=0.413..0.413 rows=1 loops=4,133)

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

Index Scan using pk_user_group on user_group ug_2 (cost=0.13..0.15 rows=1 width=278) (actual time=0.000..0.000 rows=0 loops=4,133)

  • Index Cond: (du_1.user_group_id = id)
18. 0.472 969.050 ↓ 32.6 261 1

Nested Loop Left Join (cost=7.19..31,761.65 rows=8 width=311) (actual time=4.146..969.050 rows=261 loops=1)

  • Join Filter: (du_2.user_group_id = ug_3.id)
  • Rows Removed by Join Filter: 2,088
19. 0.373 968.056 ↓ 32.6 261 1

Nested Loop Left Join (cost=7.19..31,759.59 rows=8 width=37) (actual time=4.130..968.056 rows=261 loops=1)

20. 0.288 860.673 ↓ 32.6 261 1

Merge Join (cost=6.91..31,757.03 rows=8 width=24) (actual time=3.644..860.673 rows=261 loops=1)

  • Merge Cond: (prg.id = crg.flowdown_rolegroup)
21. 25.003 860.266 ↑ 22.0 261 1

Nested Loop (cost=0.57..4,335,383.42 rows=5,735 width=20) (actual time=3.602..860.266 rows=261 loops=1)

  • Join Filter: (du_2.role_group_id = prg.id)
  • Rows Removed by Join Filter: 148,121
22. 0.143 0.143 ↓ 1.1 13 1

Index Scan using pk_role_group on role_group prg (cost=0.14..16.83 rows=12 width=4) (actual time=0.013..0.143 rows=13 loops=1)

  • Filter: (entity_type_id = 1)
  • Rows Removed by Filter: 215
23. 23.647 835.120 ↑ 9.0 11,414 13

Materialize (cost=0.42..4,317,042.20 rows=103,236 width=16) (actual time=0.276..64.240 rows=11,414 loops=13)

24. 5.974 811.473 ↑ 9.0 11,414 1

Nested Loop (cost=0.42..4,316,526.02 rows=103,236 width=16) (actual time=3.583..811.473 rows=11,414 loops=1)

25. 556.656 614.967 ↑ 9.6 4,142 1

Subquery Scan on et (cost=0.00..4,132,616.04 rows=39,868 width=8) (actual time=3.565..614.967 rows=4,142 loops=1)

  • Filter: ((((change_tz(et.exp_date, 'UTC'::character varying, 'IST'::character varying))::date >= '2020-07-24 00:00:00'::timestamp without time zone) AND ((change_tz(et.exp_date, 'UTC'::character varying, 'IST'::character varying))::date <= '2020-09-15 00:00:00'::timestamp without time zone)) OR (((change_tz(et.notice_lead_date, 'UTC'::character varying, 'IST'::character varying))::date >= '2020-07-24 00:00:00'::timestamp without time zone) AND ((change_tz(et.notice_lead_date, 'UTC'::character varying, 'IST'::character varying))::date <= '2020-09-15 00:00:00'::timestamp without time zone)) OR (((change_tz(et.notice_date, 'UTC'::character varying, 'IST'::character varying))::date >= '2020-07-24 00:00:00'::timestamp without time zone) AND ((change_tz(et.notice_date, 'UTC'::character varying, 'IST'::character varying))::date <= '2020-09-15 00:00:00'::timestamp without time zone)))
  • Rows Removed by Filter: 23,433
26. 32.053 58.311 ↑ 96.9 27,575 1

ProjectSet (cost=0.00..18,968.04 rows=2,671,200 width=32) (actual time=0.016..58.311 rows=27,575 loops=1)

27. 26.258 26.258 ↑ 1.0 26,698 1

Seq Scan on contract (cost=0.00..5,411.70 rows=26,712 width=53) (actual time=0.008..26.258 rows=26,698 loops=1)

  • Filter: (NOT deleted)
  • Rows Removed by Filter: 7,677
28. 107.453 190.532 ↑ 1.0 3 4,142

Index Scan using idx_domain_user_entity_id_role_group_id on domain_user du_2 (cost=0.42..4.58 rows=3 width=16) (actual time=0.013..0.046 rows=3 loops=4,142)

  • Index Cond: (entity_id = et.relation_id)
  • Filter: ((user_id = 1,044) OR (SubPlan 2))
  • Rows Removed by Filter: 20
29.          

SubPlan (for Index Scan)

30. 0.000 83.079 ↓ 0.0 0 83,079

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

31. 83.079 83.079 ↓ 0.0 0 83,079

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

  • Filter: (id = du_2.user_group_id)
  • Rows Removed by Filter: 8
32. 0.090 0.119 ↓ 87.3 262 1

Sort (cost=6.34..6.35 rows=3 width=16) (actual time=0.036..0.119 rows=262 loops=1)

  • Sort Key: crg.flowdown_rolegroup
  • Sort Method: quicksort Memory: 25kB
33. 0.009 0.029 ↑ 1.5 2 1

Bitmap Heap Scan on role_group crg (cost=3.14..6.32 rows=3 width=16) (actual time=0.024..0.029 rows=2 loops=1)

  • Recheck Cond: ((entity_type_id = 61) AND (client_id = 1,002))
  • Heap Blocks: exact=5
34. 0.002 0.020 ↓ 0.0 0 1

BitmapAnd (cost=3.14..3.14 rows=3 width=0) (actual time=0.020..0.020 rows=0 loops=1)

35. 0.009 0.009 ↓ 1.2 20 1

Bitmap Index Scan on role_group_entity_type_id_idx (cost=0.00..1.37 rows=16 width=0) (actual time=0.009..0.009 rows=20 loops=1)

  • Index Cond: (entity_type_id = 61)
36. 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)
37. 107.010 107.010 ↑ 1.0 1 261

Index Scan using pk_app_user on app_user u_1 (cost=0.28..0.32 rows=1 width=17) (actual time=0.410..0.410 rows=1 loops=261)

  • Index Cond: (du_2.user_id = id)
38. 0.516 0.522 ↑ 1.0 8 261

Materialize (cost=0.00..1.12 rows=8 width=278) (actual time=0.000..0.002 rows=8 loops=261)

39. 0.006 0.006 ↑ 1.0 8 1

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

40. 35.931 3,533.757 ↓ 318.6 4,142 1

HashAggregate (cost=7.38..10.96 rows=13 width=267) (actual time=3,505.477..3,533.757 rows=4,142 loops=1)

  • Group Key: c.id, r.name, ets.description
41. 11.033 3,497.826 ↓ 635.1 8,256 1

Nested Loop Left Join (cost=1.27..7.16 rows=13 width=1,453) (actual time=3,425.546..3,497.826 rows=8,256 loops=1)

42. 6.553 3,478.546 ↓ 8,247.0 8,247 1

Nested Loop (cost=0.99..4.04 rows=1 width=1,427) (actual time=3,425.532..3,478.546 rows=8,247 loops=1)

43. 5.460 3,463.746 ↓ 8,247.0 8,247 1

Nested Loop (cost=0.71..3.74 rows=1 width=1,409) (actual time=3,425.520..3,463.746 rows=8,247 loops=1)

44. 2.962 3,445.887 ↓ 4,133.0 4,133 1

Nested Loop (cost=0.29..3.03 rows=1 width=1,413) (actual time=3,425.503..3,445.887 rows=4,133 loops=1)

45. 3,430.526 3,430.526 ↓ 4,133.0 4,133 1

CTE Scan on domain_user_with_flowdown_rgs du (cost=0.00..0.49 rows=1 width=1,314) (actual time=3,425.481..3,430.526 rows=4,133 loops=1)

  • Filter: (role_group_id = 2,001)
  • Rows Removed by Filter: 261
46. 12.399 12.399 ↑ 1.0 1 4,133

Index Scan using pk_contract on contract c (cost=0.29..2.54 rows=1 width=99) (actual time=0.003..0.003 rows=1 loops=4,133)

  • Index Cond: (id = du.entity_id)
  • Filter: ((NOT deleted) AND (client_id = 1,002) AND (status_id = ANY ('{1610,1608,1606,1604,1607,1603,1605,1609,5,1515,1,1474,1473,1471,6,1517,1470,2,1472,1516}'::integer[])))
47. 12.399 12.399 ↑ 1.0 2 4,133

Index Only Scan using idx_link_entity_function_6 on link_entity_function lef (cost=0.42..0.69 rows=2 width=4) (actual time=0.003..0.003 rows=2 loops=4,133)

  • Index Cond: ((entity_id = c.id) AND (entity_type_id = 61))
  • Heap Fetches: 8,281
48. 8.247 8.247 ↑ 1.0 1 8,247

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=8,247)

  • Index Cond: (id = c.status_id)
49. 8.247 8.247 ↑ 10.0 1 8,247

Index Scan using pk_relation on relation r (cost=0.28..3.02 rows=10 width=55) (actual time=0.001..0.001 rows=1 loops=8,247)

  • Index Cond: (id = ANY (c.relation_ids))
Planning time : 5.276 ms
Execution time : 3,536.563 ms