explain.depesz.com

PostgreSQL's explain analyze made readable

Result: J1cX

Settings
# exclusive inclusive rows x rows loops node
1. 6.326 2,655.648 ↓ 15.0 11,329 1

Nested Loop (cost=2.39..270,386.50 rows=753 width=152) (actual time=1.143..2,655.648 rows=11,329 loops=1)

2. 1.774 1.774 ↑ 1.0 753 1

Seq Scan on auth_user u (cost=0.00..418.33 rows=753 width=4) (actual time=0.011..1.774 rows=753 loops=1)

  • Filter: is_active
  • Rows Removed by Filter: 1880
3. 106.395 2,647.548 ↓ 15.0 15 753

Nested Loop Semi Join (cost=2.39..358.50 rows=1 width=152) (actual time=0.105..3.516 rows=15 loops=753)

  • Join Filter: (p.id = c_2.partner_id)
4. 19.140 585.834 ↑ 1.1 16 753

Nested Loop Anti Join (cost=1.14..274.85 rows=18 width=29) (actual time=0.055..0.778 rows=16 loops=753)

5. 33.762 459.330 ↑ 1.4 36 753

Nested Loop (cost=0.85..253.60 rows=50 width=29) (actual time=0.043..0.610 rows=36 loops=753)

6. 6.009 210.840 ↑ 1.4 36 753

Nested Loop (cost=0.56..237.43 rows=50 width=20) (actual time=0.042..0.280 rows=36 loops=753)

7. 13.554 13.554 ↑ 1.0 1 753

Index Scan using partners_partnermanager_e8701ad4 on partners_partnermanager m (cost=0.28..2.29 rows=1 width=8) (actual time=0.017..0.018 rows=1 loops=753)

  • Index Cond: (user_id = u.id)
8. 191.277 191.277 ↑ 4.2 56 477

Index Scan using partners_partnercontract_3f984797 on partners_partnercontract c (cost=0.29..232.77 rows=236 width=20) (actual time=0.075..0.401 rows=56 loops=477)

  • Index Cond: (sales_manager_id = m.id)
9. 214.728 214.728 ↑ 1.0 1 26,841

Index Scan using partners_partner_pkey on partners_partner p (cost=0.29..0.32 rows=1 width=9) (actual time=0.008..0.008 rows=1 loops=26,841)

  • Index Cond: (id = c.partner_id)
10. 107.364 107.364 ↑ 1.0 1 26,841

Index Only Scan using idx_partner_contract_is_involved on partners_partnercontract c_1 (cost=0.29..0.42 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=26,841)

  • Index Cond: (partner_id = p.id)
  • Heap Fetches: 14609
11. 48.838 244.640 ↑ 1.0 1 12,232

Nested Loop (cost=1.25..3.54 rows=1 width=4) (actual time=0.020..0.020 rows=1 loops=12,232)

  • Join Filter: ((m_1.user_id = uc.user_id) AND ((c_2.brand)::text = (CASE WHEN ((uc.brand)::text = 'ratehawk'::text) THEN uc.brand ELSE 'ostrovok'::character varying END)::text))
  • Rows Removed by Join Filter: 0
12. 24.404 159.016 ↑ 1.0 1 12,232

Nested Loop (cost=0.84..1.11 rows=1 width=21) (actual time=0.013..0.013 rows=1 loops=12,232)

13. 12.112 110.088 ↑ 1.0 1 12,232

Nested Loop (cost=0.56..0.69 rows=1 width=17) (actual time=0.009..0.009 rows=1 loops=12,232)

14. 61.160 61.160 ↑ 1.0 1 12,232

Index Scan using partners_partnercontract_4e98b6eb on partners_partnercontract c_2 (cost=0.29..0.40 rows=1 width=17) (actual time=0.005..0.005 rows=1 loops=12,232)

  • Index Cond: (partner_id = c.partner_id)
15. 36.816 36.816 ↑ 1.0 1 12,272

Index Scan using partners_partnermanager_pkey on partners_partnermanager m_1 (cost=0.28..0.29 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=12,272)

  • Index Cond: (id = c_2.sales_manager_id)
16. 24.524 24.524 ↑ 1.0 1 12,262

Index Only Scan using auth_user_pkey on auth_user u_1 (cost=0.28..0.42 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=12,262)

  • Index Cond: (id = m_1.user_id)
  • Heap Fetches: 462
17. 36.786 36.786 ↑ 1.0 1 12,262

Index Scan using profile_userconfig_user_id_key on profile_userconfig uc (cost=0.41..2.41 rows=1 width=9) (actual time=0.003..0.003 rows=1 loops=12,262)

  • Index Cond: (user_id = u_1.id)
18.          

SubPlan (forNested Loop Semi Join)

19. 45.316 1,019.610 ↑ 1.0 1 11,329

Aggregate (cost=3.91..3.92 rows=1 width=8) (actual time=0.090..0.090 rows=1 loops=11,329)

20. 781.701 974.294 ↓ 0.0 0 11,329

Bitmap Heap Scan on crm_asterisk_attachedcall call (cost=2.89..3.91 rows=1 width=0) (actual time=0.076..0.086 rows=0 loops=11,329)

  • Recheck Cond: ((((related_to_model)::text = 'Partner'::text) AND (related_to_id = c.partner_id)) OR (((related_to_model)::text = 'PartnerContract'::text) AND (related_to_id = c.id)))
  • Filter: (created_by_id = $0)
  • Rows Removed by Filter: 0
  • Heap Blocks: exact=1431
21. 22.658 192.593 ↓ 0.0 0 11,329

BitmapOr (cost=2.89..2.89 rows=1 width=0) (actual time=0.017..0.017 rows=0 loops=11,329)

22. 90.632 90.632 ↓ 0.0 0 11,329

Bitmap Index Scan on idx_crm_asterisk_attachedcall_related (cost=0.00..1.44 rows=1 width=0) (actual time=0.008..0.008 rows=0 loops=11,329)

  • Index Cond: (((related_to_model)::text = 'Partner'::text) AND (related_to_id = c.partner_id))
23. 79.303 79.303 ↓ 0.0 0 11,329

Bitmap Index Scan on idx_crm_asterisk_attachedcall_related (cost=0.00..1.44 rows=1 width=0) (actual time=0.007..0.007 rows=0 loops=11,329)

  • Index Cond: (((related_to_model)::text = 'PartnerContract'::text) AND (related_to_id = c.id))
24. 56.645 385.186 ↑ 1.0 1 11,329

Aggregate (cost=3.89..3.90 rows=1 width=8) (actual time=0.034..0.034 rows=1 loops=11,329)

25. 147.277 328.541 ↓ 0.0 0 11,329

Bitmap Heap Scan on action_log_action al (cost=2.86..3.88 rows=1 width=0) (actual time=0.029..0.029 rows=0 loops=11,329)

  • Recheck Cond: ((((related_to_model)::text = 'Partner'::text) AND (related_to_id = c.partner_id)) OR (((related_to_model)::text = 'PartnerContract'::text) AND (related_to_id = c.id)))
  • Filter: (created_by_id = $0)
  • Rows Removed by Filter: 0
  • Heap Blocks: exact=3274
26. 0.000 181.264 ↓ 0.0 0 11,329

BitmapOr (cost=2.86..2.86 rows=1 width=0) (actual time=0.016..0.016 rows=0 loops=11,329)

27. 113.290 113.290 ↓ 0.0 0 11,329

Bitmap Index Scan on idx_action_log_instance__index (cost=0.00..1.43 rows=1 width=0) (actual time=0.010..0.010 rows=0 loops=11,329)

  • Index Cond: (((related_to_model)::text = 'Partner'::text) AND (related_to_id = c.partner_id))
28. 67.974 67.974 ↓ 0.0 0 11,329

Bitmap Index Scan on idx_action_log_instance__index (cost=0.00..1.43 rows=1 width=0) (actual time=0.006..0.006 rows=0 loops=11,329)

  • Index Cond: (((related_to_model)::text = 'PartnerContract'::text) AND (related_to_id = c.id))
29. 33.987 181.264 ↑ 1.0 1 11,329

Result (cost=5.95..5.96 rows=1 width=32) (actual time=0.016..0.016 rows=1 loops=11,329)

30.          

Initplan (forResult)

31. 33.987 147.277 ↓ 0.0 0 11,329

Sort (cost=5.94..5.95 rows=1 width=12) (actual time=0.013..0.013 rows=0 loops=11,329)

  • Sort Key: r.remind_dt
  • Sort Method: quicksort Memory: 25kB
32. 22.658 113.290 ↓ 0.0 0 11,329

Bitmap Heap Scan on reminds_remind r (cost=2.85..5.93 rows=1 width=12) (actual time=0.010..0.010 rows=0 loops=11,329)

  • Recheck Cond: ((related_to_id = c.partner_id) OR (related_to_id = c.id))
  • Filter: ((created_by_id = $0) AND (remind_dt >= now()) AND ((((related_to_model)::text = 'Partner'::text) AND (related_to_id = c.partner_id)) OR (((related_to_model)::text = 'PartnerContract'::text) AND (related_to_id = c.id))))
  • Rows Removed by Filter: 0
  • Heap Blocks: exact=3215
33. 0.000 90.632 ↓ 0.0 0 11,329

BitmapOr (cost=2.85..2.85 rows=3 width=0) (actual time=0.008..0.008 rows=0 loops=11,329)

34. 56.645 56.645 ↓ 0.0 0 11,329

Bitmap Index Scan on reminds_remind_f1e30255 (cost=0.00..1.43 rows=1 width=0) (actual time=0.005..0.005 rows=0 loops=11,329)

  • Index Cond: (related_to_id = c.partner_id)
35. 33.987 33.987 ↓ 0.0 0 11,329

Bitmap Index Scan on reminds_remind_f1e30255 (cost=0.00..1.43 rows=1 width=0) (actual time=0.003..0.003 rows=0 loops=11,329)

  • Index Cond: (related_to_id = c.id)
36. 45.316 124.619 ↑ 1.0 1 11,329

Aggregate (cost=5.94..5.95 rows=1 width=32) (actual time=0.011..0.011 rows=1 loops=11,329)

37. 22.658 79.303 ↓ 0.0 0 11,329

Bitmap Heap Scan on reminds_remind r_1 (cost=2.85..5.93 rows=1 width=8) (actual time=0.007..0.007 rows=0 loops=11,329)

  • Recheck Cond: ((related_to_id = c.partner_id) OR (related_to_id = c.id))
  • Filter: ((created_by_id = $0) AND (remind_dt >= now()) AND ((((related_to_model)::text = 'Partner'::text) AND (related_to_id = c.partner_id)) OR (((related_to_model)::text = 'PartnerContract'::text) AND (related_to_id = c.id))))
  • Rows Removed by Filter: 0
  • Heap Blocks: exact=3215
38. 0.000 56.645 ↓ 0.0 0 11,329

BitmapOr (cost=2.85..2.85 rows=3 width=0) (actual time=0.005..0.005 rows=0 loops=11,329)

39. 33.987 33.987 ↓ 0.0 0 11,329

Bitmap Index Scan on reminds_remind_f1e30255 (cost=0.00..1.43 rows=1 width=0) (actual time=0.003..0.003 rows=0 loops=11,329)

  • Index Cond: (related_to_id = c.partner_id)
40. 22.658 22.658 ↓ 0.0 0 11,329

Bitmap Index Scan on reminds_remind_f1e30255 (cost=0.00..1.43 rows=1 width=0) (actual time=0.002..0.002 rows=0 loops=11,329)

  • Index Cond: (related_to_id = c.id)
Planning time : 8.996 ms
Execution time : 2,657.395 ms