explain.depesz.com

PostgreSQL's explain analyze made readable

Result: pSk

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 10.209 ↓ 2.6 42 1

Limit (cost=473.23..473.27 rows=16 width=504) (actual time=10.203..10.209 rows=42 loops=1)

2. 0.055 10.205 ↓ 2.6 42 1

Sort (cost=473.23..473.27 rows=16 width=504) (actual time=10.202..10.205 rows=42 loops=1)

  • Sort Key: client_contract.creation_date DESC
  • Sort Method: quicksort Memory: 54kB
3. 1.542 10.150 ↓ 2.6 42 1

Hash Right Join (cost=329.72..472.91 rows=16 width=504) (actual time=9.915..10.150 rows=42 loops=1)

  • Hash Cond: ((assigned_territories.uuid)::text = COALESCE(lbto.office_uuid, lbto_def.office_uuid))
4. 0.769 0.769 ↑ 1.0 3,176 1

Seq Scan on assigned_territories (cost=0.00..122.87 rows=3,187 width=16) (actual time=0.010..0.769 rows=3,176 loops=1)

5. 0.118 7.839 ↓ 42.0 42 1

Hash (cost=329.71..329.71 rows=1 width=858) (actual time=7.838..7.839 rows=42 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 37kB
6. 0.026 7.721 ↓ 42.0 42 1

Nested Loop Left Join (cost=9.59..329.71 rows=1 width=858) (actual time=0.423..7.721 rows=42 loops=1)

7. 0.029 7.485 ↓ 42.0 42 1

Nested Loop Left Join (cost=9.31..325.73 rows=1 width=825) (actual time=0.413..7.485 rows=42 loops=1)

8. 0.047 7.204 ↓ 42.0 42 1

Nested Loop Left Join (cost=9.02..323.22 rows=1 width=792) (actual time=0.400..7.204 rows=42 loops=1)

9. 0.036 6.947 ↓ 42.0 42 1

Nested Loop Left Join (cost=8.74..320.84 rows=1 width=765) (actual time=0.390..6.947 rows=42 loops=1)

10. 0.046 6.659 ↓ 42.0 42 1

Nested Loop Left Join (cost=8.45..318.33 rows=1 width=722) (actual time=0.380..6.659 rows=42 loops=1)

11. 0.044 6.613 ↓ 42.0 42 1

Nested Loop Left Join (cost=8.17..315.82 rows=1 width=695) (actual time=0.370..6.613 rows=42 loops=1)

  • Join Filter: (creator_def.code = client_contract.creator_id)
12. 0.058 6.317 ↓ 42.0 42 1

Nested Loop Left Join (cost=7.88..313.30 rows=1 width=648) (actual time=0.360..6.317 rows=42 loops=1)

13. 0.088 5.965 ↓ 42.0 42 1

Nested Loop Left Join (cost=7.46..312.84 rows=1 width=627) (actual time=0.347..5.965 rows=42 loops=1)

14. 0.103 5.373 ↓ 42.0 42 1

Nested Loop Left Join (cost=6.90..310.62 rows=1 width=572) (actual time=0.330..5.373 rows=42 loops=1)

  • Join Filter: (contract_status_def.code = client_contract.status_id)
  • Rows Removed by Join Filter: 136
15. 0.094 5.186 ↓ 42.0 42 1

Nested Loop Left Join (cost=6.90..309.27 rows=1 width=547) (actual time=0.321..5.186 rows=42 loops=1)

  • Join Filter: (contract_type_def.code = client_contract.type_id)
  • Rows Removed by Join Filter: 44
16. 0.045 5.050 ↓ 42.0 42 1

Nested Loop Left Join (cost=6.90..308.12 rows=1 width=508) (actual time=0.313..5.050 rows=42 loops=1)

17. 0.047 4.795 ↓ 42.0 42 1

Nested Loop Left Join (cost=6.63..305.99 rows=1 width=471) (actual time=0.298..4.795 rows=42 loops=1)

18. 0.061 4.496 ↓ 42.0 42 1

Nested Loop Left Join (cost=6.34..303.48 rows=1 width=438) (actual time=0.282..4.496 rows=42 loops=1)

19. 0.063 4.225 ↓ 42.0 42 1

Nested Loop Left Join (cost=6.06..301.10 rows=1 width=407) (actual time=0.268..4.225 rows=42 loops=1)

20. 0.023 3.910 ↓ 42.0 42 1

Nested Loop (cost=5.77..298.59 rows=1 width=359) (actual time=0.257..3.910 rows=42 loops=1)

21. 0.019 3.635 ↓ 42.0 42 1

Nested Loop (cost=5.49..296.08 rows=1 width=332) (actual time=0.243..3.635 rows=42 loops=1)

22. 0.016 3.280 ↓ 42.0 42 1

Nested Loop (cost=5.20..293.56 rows=1 width=280) (actual time=0.223..3.280 rows=42 loops=1)

23. 0.077 2.886 ↓ 42.0 42 1

Nested Loop Left Join (cost=4.78..290.91 rows=1 width=259) (actual time=0.195..2.886 rows=42 loops=1)

  • Join Filter: (contract_status.code = client_contract.status_id)
  • Rows Removed by Join Filter: 136
24. 0.098 2.725 ↓ 42.0 42 1

Nested Loop Left Join (cost=4.78..289.56 rows=1 width=232) (actual time=0.186..2.725 rows=42 loops=1)

  • Join Filter: (contract_type.code = client_contract.type_id)
  • Rows Removed by Join Filter: 44
25. 0.551 2.585 ↓ 42.0 42 1

Nested Loop Left Join (cost=4.78..288.41 rows=1 width=191) (actual time=0.168..2.585 rows=42 loops=1)

26. 0.016 1.908 ↓ 42.0 42 1

Nested Loop Left Join (cost=1.69..284.07 rows=1 width=183) (actual time=0.134..1.908 rows=42 loops=1)

27. 0.092 1.766 ↓ 42.0 42 1

Nested Loop Left Join (cost=1.41..283.03 rows=1 width=183) (actual time=0.122..1.766 rows=42 loops=1)

  • Join Filter: (currency.code = contracts_currencies.currency_id)
  • Rows Removed by Join Filter: 213
28. 0.037 1.422 ↓ 42.0 42 1

Nested Loop Left Join (cost=1.41..279.97 rows=1 width=174) (actual time=0.105..1.422 rows=42 loops=1)

29. 0.066 1.049 ↓ 42.0 42 1

Nested Loop (cost=0.98..277.32 rows=1 width=172) (actual time=0.088..1.049 rows=42 loops=1)

30. 0.184 0.184 ↓ 5.2 47 1

Index Scan using idx_client_contract_creator on client_contract (cost=0.43..242.31 rows=9 width=84) (actual time=0.031..0.184 rows=47 loops=1)

  • Index Cond: (creator_id = '31399'::text)
  • Filter: ((responsible_office_id = '1210'::text) OR (responsible_office_id = '44'::text))
  • Rows Removed by Filter: 1
31. 0.799 0.799 ↑ 1.0 1 47

Index Scan using contragent_pkey on contragent (cost=0.56..3.89 rows=1 width=88) (actual time=0.017..0.017 rows=1 loops=47)

  • Index Cond: ((id = client_contract.contragent_id) AND (lang = 'rus'::text))
  • Filter: (city_code = '44'::text)
  • Rows Removed by Filter: 0
32. 0.336 0.336 ↑ 1.0 1 42

Index Only Scan using contracts_currencies_pkey on contracts_currencies (cost=0.42..2.64 rows=1 width=6) (actual time=0.008..0.008 rows=1 loops=42)

  • Index Cond: (contract_id = client_contract.id)
  • Heap Fetches: 42
33. 0.252 0.252 ↑ 2.8 6 42

Seq Scan on currency (cost=0.00..2.85 rows=17 width=13) (actual time=0.003..0.006 rows=6 loops=42)

  • Filter: (lang = 'rus'::text)
  • Rows Removed by Filter: 16
34. 0.126 0.126 ↓ 0.0 0 42

Index Only Scan using contracts_reverse_rule_idx on contracts_reverse_rule (cost=0.28..1.03 rows=1 width=4) (actual time=0.003..0.003 rows=0 loops=42)

  • Index Cond: (contract_id = client_contract.id)
  • Heap Fetches: 0
35. 0.000 0.126 ↑ 1.0 1 42

Index Only Scan using contract_id_status_code_change_date_unique on contract_status_history csh (cost=3.09..4.34 rows=1 width=14) (actual time=0.003..0.003 rows=1 loops=42)

  • Index Cond: ((contract_id = client_contract.id) AND (status_code = client_contract.status_id) AND (change_date = (SubPlan 2)))
  • Heap Fetches: 0
36.          

SubPlan (for Index Only Scan)

37. 0.042 0.462 ↑ 1.0 1 42

Result (cost=2.65..2.66 rows=1 width=8) (actual time=0.010..0.011 rows=1 loops=42)

38.          

Initplan (for Result)

39. 0.042 0.420 ↑ 1.0 1 42

Limit (cost=0.43..2.65 rows=1 width=8) (actual time=0.009..0.010 rows=1 loops=42)

40. 0.378 0.378 ↑ 1.0 1 42

Index Only Scan Backward using contract_id_status_code_change_date_unique on contract_status_history cshi (cost=0.43..2.65 rows=1 width=8) (actual time=0.008..0.009 rows=1 loops=42)

  • Index Cond: ((contract_id = client_contract.id) AND (status_code = client_contract.status_id) AND (change_date IS NOT NULL))
  • Heap Fetches: 0
41. 0.042 0.042 ↑ 1.5 2 42

Seq Scan on contract_type (cost=0.00..1.11 rows=3 width=41) (actual time=0.001..0.001 rows=2 loops=42)

  • Filter: (lang = 'rus'::text)
42. 0.084 0.084 ↑ 1.8 4 42

Seq Scan on contract_status (cost=0.00..1.26 rows=7 width=29) (actual time=0.001..0.002 rows=4 loops=42)

  • Filter: (lang = 'rus'::text)
43. 0.378 0.378 ↑ 1.0 1 42

Index Scan using city_code_lang_key on city contragentcity (cost=0.42..2.64 rows=1 width=30) (actual time=0.008..0.009 rows=1 loops=42)

  • Index Cond: ((code = '44'::text) AND (lang = 'rus'::text))
44. 0.336 0.336 ↑ 1.0 1 42

Index Scan using users_catalog_code_lang_key on users_catalog creator (cost=0.29..2.51 rows=1 width=57) (actual time=0.007..0.008 rows=1 loops=42)

  • Index Cond: ((code = '31399'::text) AND (lang = 'rus'::text))
  • Filter: (subdivision_id = '458'::text)
45. 0.252 0.252 ↑ 1.0 1 42

Index Scan using subdivision_code_lang_key on subdivision creatorsubdivision (cost=0.28..2.50 rows=1 width=35) (actual time=0.005..0.006 rows=1 loops=42)

  • Index Cond: ((code = '458'::text) AND (lang = 'rus'::text))
46. 0.252 0.252 ↑ 1.0 1 42

Index Scan using users_catalog_code_lang_key on users_catalog auditor (cost=0.29..2.51 rows=1 width=53) (actual time=0.006..0.006 rows=1 loops=42)

  • Index Cond: ((code = client_contract.auditor_id) AND (lang = 'rus'::text))
47. 0.210 0.210 ↑ 1.0 1 42

Index Scan using subdivision_code_lang_key on subdivision (cost=0.28..2.38 rows=1 width=35) (actual time=0.005..0.005 rows=1 loops=42)

  • Index Cond: ((code = client_contract.subdivision_id) AND (lang = 'rus'::text))
48. 0.252 0.252 ↑ 1.0 1 42

Index Scan using branch_code_lang_key on branch responsible_office (cost=0.29..2.50 rows=1 width=38) (actual time=0.006..0.006 rows=1 loops=42)

  • Index Cond: ((code = client_contract.responsible_office_id) AND (lang = 'rus'::text))
49. 0.210 0.210 ↑ 1.0 1 42

Index Scan using link_branch_to_office_branch_code_key on link_branch_to_office lbto (cost=0.28..2.13 rows=1 width=42) (actual time=0.005..0.005 rows=1 loops=42)

  • Index Cond: (branch_code = client_contract.responsible_office_id)
  • Filter: (lang = 'rus'::text)
50. 0.042 0.042 ↑ 1.5 2 42

Seq Scan on contract_type contract_type_def (cost=0.00..1.11 rows=3 width=41) (actual time=0.001..0.001 rows=2 loops=42)

  • Filter: (lang = 'eng'::text)
  • Rows Removed by Filter: 3
51. 0.084 0.084 ↑ 1.8 4 42

Seq Scan on contract_status contract_status_def (cost=0.00..1.26 rows=7 width=29) (actual time=0.002..0.002 rows=4 loops=42)

  • Filter: (lang = 'eng'::text)
  • Rows Removed by Filter: 7
52. 0.504 0.504 ↑ 2.0 1 42

Index Scan using contragent_pkey on contragent contragent_def (cost=0.56..3.88 rows=2 width=88) (actual time=0.012..0.012 rows=1 loops=42)

  • Index Cond: ((id = client_contract.contragent_id) AND (lang = 'eng'::text))
53. 0.294 0.294 ↑ 1.0 1 42

Index Scan using city_code_lang_key on city contragentcity_def (cost=0.42..0.46 rows=1 width=30) (actual time=0.007..0.007 rows=1 loops=42)

  • Index Cond: ((code = contragent_def.city_code) AND (lang = 'eng'::text))
54. 0.252 0.252 ↓ 0.0 0 42

Index Scan using users_catalog_code_lang_key on users_catalog creator_def (cost=0.29..2.51 rows=1 width=57) (actual time=0.006..0.006 rows=0 loops=42)

  • Index Cond: ((code = '31399'::text) AND (lang = 'eng'::text))
55. 0.000 0.000 ↓ 0.0 0 42

Index Scan using subdivision_code_lang_key on subdivision creatorsubdivision_def (cost=0.28..2.50 rows=1 width=35) (actual time=0.000..0.000 rows=0 loops=42)

  • Index Cond: ((code = creator_def.subdivision_id) AND (lang = 'eng'::text))
56. 0.252 0.252 ↓ 0.0 0 42

Index Scan using users_catalog_code_lang_key on users_catalog auditor_def (cost=0.29..2.51 rows=1 width=53) (actual time=0.006..0.006 rows=0 loops=42)

  • Index Cond: ((code = client_contract.auditor_id) AND (lang = 'eng'::text))
57. 0.210 0.210 ↑ 1.0 1 42

Index Scan using subdivision_code_lang_key on subdivision subdivision_def (cost=0.28..2.38 rows=1 width=35) (actual time=0.005..0.005 rows=1 loops=42)

  • Index Cond: ((code = client_contract.subdivision_id) AND (lang = 'eng'::text))
58. 0.252 0.252 ↑ 1.0 1 42

Index Scan using branch_code_lang_key on branch responsible_office_def (cost=0.29..2.50 rows=1 width=38) (actual time=0.005..0.006 rows=1 loops=42)

  • Index Cond: ((code = client_contract.responsible_office_id) AND (lang = 'eng'::text))
59. 0.210 0.210 ↓ 0.0 0 42

Index Scan using link_branch_to_office_branch_code_key on link_branch_to_office lbto_def (cost=0.28..2.13 rows=1 width=42) (actual time=0.005..0.005 rows=0 loops=42)

  • Index Cond: (branch_code = client_contract.responsible_office_id)
  • Filter: (lang = 'eng'::text)
  • Rows Removed by Filter: 1
Planning time : 94.566 ms
Execution time : 10.714 ms