explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 2PvG

Settings
# exclusive inclusive rows x rows loops node
1. 0.313 100.499 ↓ 1,067.0 1,067 1

Nested Loop (cost=2.67..505.21 rows=1 width=152) (actual time=0.322..100.499 rows=1,067 loops=1)

2. 0.010 0.010 ↑ 1.0 1 1

Index Scan using auth_user_pkey on auth_user u (cost=0.28..2.30 rows=1 width=4) (actual time=0.009..0.010 rows=1 loops=1)

  • Index Cond: (id = 162)
  • Filter: is_active
3. 5.450 100.176 ↓ 1,067.0 1,067 1

Nested Loop Semi Join (cost=2.39..502.89 rows=1 width=152) (actual time=0.311..100.176 rows=1,067 loops=1)

  • Join Filter: (p.id = c_2.partner_id)
4. 2.400 25.452 ↓ 73.7 1,327 1

Nested Loop Anti Join (cost=1.14..274.84 rows=18 width=29) (actual time=0.118..25.452 rows=1,327 loops=1)

5. 3.411 17.450 ↓ 56.0 2,801 1

Nested Loop (cost=0.85..253.60 rows=50 width=29) (actual time=0.029..17.450 rows=2,801 loops=1)

6. 0.633 5.636 ↓ 56.0 2,801 1

Nested Loop (cost=0.56..237.43 rows=50 width=20) (actual time=0.022..5.636 rows=2,801 loops=1)

7. 0.006 0.006 ↑ 1.0 1 1

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

  • Index Cond: (user_id = u.id)
8. 4.997 4.997 ↓ 11.9 2,801 1

Index Scan using partners_partnercontract_3f984797 on partners_partnercontract c (cost=0.29..232.77 rows=236 width=20) (actual time=0.015..4.997 rows=2,801 loops=1)

  • Index Cond: (sales_manager_id = m.id)
9. 8.403 8.403 ↑ 1.0 1 2,801

Index Scan using partners_partner_pkey on partners_partner p (cost=0.29..0.32 rows=1 width=9) (actual time=0.003..0.003 rows=1 loops=2,801)

  • Index Cond: (id = c.partner_id)
10. 5.602 5.602 ↑ 1.0 1 2,801

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.002..0.002 rows=1 loops=2,801)

  • Index Cond: (partner_id = p.id)
  • Heap Fetches: 1474
11. 1.327 15.924 ↑ 1.0 1 1,327

Nested Loop (cost=1.25..3.54 rows=1 width=4) (actual time=0.012..0.012 rows=1 loops=1,327)

  • 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. 2.654 11.943 ↑ 1.0 1 1,327

Nested Loop (cost=0.84..1.12 rows=1 width=21) (actual time=0.009..0.009 rows=1 loops=1,327)

13. 1.325 7.962 ↑ 1.0 1 1,327

Nested Loop (cost=0.56..0.69 rows=1 width=17) (actual time=0.006..0.006 rows=1 loops=1,327)

14. 3.981 3.981 ↑ 1.0 1 1,327

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

  • Index Cond: (partner_id = c.partner_id)
15. 2.656 2.656 ↑ 1.0 1 1,328

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

  • Index Cond: (id = c_2.sales_manager_id)
16. 1.327 1.327 ↑ 1.0 1 1,327

Index Only Scan using auth_user_pkey on auth_user u_1 (cost=0.28..0.43 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=1,327)

  • Index Cond: (id = m_1.user_id)
  • Heap Fetches: 0
17. 2.654 2.654 ↑ 1.0 1 1,327

Index Scan using profile_userconfig_user_id_key on profile_userconfig uc (cost=0.41..2.40 rows=1 width=9) (actual time=0.002..0.002 rows=1 loops=1,327)

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

SubPlan (forNested Loop Semi Join)

19. 1.067 13.871 ↑ 1.0 1 1,067

Aggregate (cost=3.91..3.92 rows=1 width=8) (actual time=0.013..0.013 rows=1 loops=1,067)

20. 1.067 12.804 ↓ 0.0 0 1,067

Bitmap Heap Scan on crm_asterisk_attachedcall call (cost=2.89..3.91 rows=1 width=0) (actual time=0.012..0.012 rows=0 loops=1,067)

  • 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=2
21. 1.067 11.737 ↓ 0.0 0 1,067

BitmapOr (cost=2.89..2.89 rows=1 width=0) (actual time=0.011..0.011 rows=0 loops=1,067)

22. 5.335 5.335 ↓ 0.0 0 1,067

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

  • Index Cond: (((related_to_model)::text = 'Partner'::text) AND (related_to_id = c.partner_id))
23. 5.335 5.335 ↓ 0.0 0 1,067

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

  • Index Cond: (((related_to_model)::text = 'PartnerContract'::text) AND (related_to_id = c.id))
24. 2.134 12.804 ↑ 1.0 1 1,067

Aggregate (cost=3.89..3.90 rows=1 width=8) (actual time=0.012..0.012 rows=1 loops=1,067)

25. 1.067 10.670 ↓ 0.0 0 1,067

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

  • 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=178
26. 0.000 9.603 ↓ 0.0 0 1,067

BitmapOr (cost=2.86..2.86 rows=1 width=0) (actual time=0.009..0.009 rows=0 loops=1,067)

27. 5.335 5.335 ↓ 0.0 0 1,067

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

  • Index Cond: (((related_to_model)::text = 'Partner'::text) AND (related_to_id = c.partner_id))
28. 4.268 4.268 ↓ 0.0 0 1,067

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

  • Index Cond: (((related_to_model)::text = 'PartnerContract'::text) AND (related_to_id = c.id))
29. 1.067 10.670 ↑ 1.0 1 1,067

Result (cost=5.95..5.96 rows=1 width=32) (actual time=0.010..0.010 rows=1 loops=1,067)

30.          

Initplan (forResult)

31. 3.201 9.603 ↓ 0.0 0 1,067

Sort (cost=5.94..5.95 rows=1 width=12) (actual time=0.009..0.009 rows=0 loops=1,067)

  • Sort Key: r.remind_dt
  • Sort Method: quicksort Memory: 25kB
32. 1.067 6.402 ↓ 0.0 0 1,067

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

  • 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=213
33. 1.067 5.335 ↓ 0.0 0 1,067

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

34. 2.134 2.134 ↓ 0.0 0 1,067

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=1,067)

  • Index Cond: (related_to_id = c.partner_id)
35. 2.134 2.134 ↓ 0.0 0 1,067

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=1,067)

  • Index Cond: (related_to_id = c.id)
36. 1.067 16.005 ↑ 1.0 1 1,067

Aggregate (cost=150.37..150.38 rows=1 width=32) (actual time=0.015..0.015 rows=1 loops=1,067)

37. 14.938 14.938 ↓ 0.0 0 1,067

Index Scan using reminds_remind_e93cb7eb on reminds_remind r_1 (cost=0.42..150.37 rows=1 width=8) (actual time=0.014..0.014 rows=0 loops=1,067)

  • Index Cond: (created_by_id = $0)
  • Filter: ((remind_dt >= now()) AND (concat(related_to_model, '_', (related_to_id)::text) = ANY (ARRAY[concat('Partner', '_', (c.partner_id)::text), concat('PartnerContract', '_', (c.id)::text)])))
  • Rows Removed by Filter: 18
Planning time : 4.474 ms
Execution time : 100.819 ms