explain.depesz.com

PostgreSQL's explain analyze made readable

Result: jMy8

Settings
# exclusive inclusive rows x rows loops node
1. 0.373 9.218 ↑ 1.5 32 1

Sort (cost=30,299.48..30,299.60 rows=48 width=1,750) (actual time=9.217..9.218 rows=32 loops=1)

  • Sort Key: (CASE WHEN (t.row_number = 31) THEN 31 ELSE NULL::integer END), ((dst."StartDateTime")::date), ((dst."EndDateTime")::date), ((dst."StartDateTime")::time without time zone), ((dst."EndDateTime")::time without time zone), t."@Документ
  • Sort Method: quicksort Memory: 84kB
2.          

CTE pre_t

3. 0.003 5.880 ↓ 31.0 31 1

Limit (cost=9,122.66..9,122.67 rows=1 width=175) (actual time=5.875..5.880 rows=31 loops=1)

4. 0.500 5.877 ↓ 31.0 31 1

Sort (cost=9,122.66..9,122.67 rows=1 width=175) (actual time=5.875..5.877 rows=31 loops=1)

  • Sort Key: "DT"."EndDateTime", "Д"."@Документ
  • Sort Method: top-N heapsort Memory: 32kB
5. 0.746 5.377 ↓ 844.0 844 1

Nested Loop (cost=0.43..9,122.65 rows=1 width=175) (actual time=0.026..5.377 rows=844 loops=1)

6. 0.263 0.263 ↓ 1.0 1,092 1

Seq Scan on "DeliveryTask" "DT" (cost=0.00..25.77 rows=1,077 width=12) (actual time=0.007..0.263 rows=1,092 loops=1)

7. 4.368 4.368 ↑ 1.0 1 1,092

Index Scan using "pДокумент" on "Документ" "Д" (cost=0.43..8.44 rows=1 width=167) (actual time=0.004..0.004 rows=1 loops=1,092)

  • Index Cond: ("@Документ" = "DT"."@Документ")
  • Filter: (("Удален" IS NOT TRUE) AND ("ТипДокумента" IS NOT NULL) AND ("ТипДокумента" = ANY ('{4958,4790}'::integer[])) AND ("ДокументНашаОрганизация" IS DISTINCT FROM 22168590) AND (("$Черновик" IS NULL) OR ("$Черновик" = 10425562)))
  • Rows Removed by Filter: 0
8.          

CTE count_pre_t

9. 0.000 0.014 ↑ 1.0 1 1

Aggregate (cost=9,162.40..9,162.41 rows=1 width=0) (actual time=0.014..0.014 rows=1 loops=1)

10.          

Initplan (for Aggregate)

11. 0.002 0.006 ↑ 1.0 1 1

Limit (cost=0.02..0.02 rows=1 width=0) (actual time=0.006..0.006 rows=1 loops=1)

12. 0.004 0.004 ↓ 31.0 31 1

CTE Scan on pre_t (cost=0.00..0.02 rows=1 width=0) (actual time=0.001..0.004 rows=31 loops=1)

13. 0.008 0.008 ↓ 0.0 0 1

Result (cost=0.72..9,162.37 rows=1 width=0) (actual time=0.008..0.008 rows=0 loops=1)

  • One-Time Filter: (NOT $2)
14. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.72..9,162.37 rows=1 width=0) (never executed)

15. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.43..9,161.89 rows=1 width=4) (never executed)

  • Join Filter: ("DT_1"."@Документ" = a0."@Документ")
16. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.43..9,122.65 rows=1 width=4) (never executed)

17. 0.000 0.000 ↓ 0.0 0

Seq Scan on "DeliveryTask" "DT_1" (cost=0.00..25.77 rows=1,077 width=4) (never executed)

18. 0.000 0.000 ↓ 0.0 0

Index Scan using "pДокумент" on "Документ" "Д_1" (cost=0.43..8.44 rows=1 width=4) (never executed)

  • Index Cond: ("@Документ" = "DT_1"."@Документ")
  • Filter: (("Удален" IS NOT TRUE) AND ("ТипДокумента" IS NOT NULL) AND ("ТипДокумента" = ANY ('{4958,4790}'::integer[])) AND ("ДокументНашаОрганизация" IS DISTINCT FROM 22168590) AND (("$Черновик" IS NULL) OR ("$Черновик" = 10425562)))
19. 0.000 0.000 ↓ 0.0 0

Seq Scan on "DeliveryTask" a0 (cost=0.00..25.77 rows=1,077 width=8) (never executed)

20. 0.000 0.000 ↓ 0.0 0

Index Only Scan using "pАдресДоставки" on "АдресДоставки" addr_dt (cost=0.28..0.48 rows=1 width=4) (never executed)

  • Index Cond: ("@АдресДоставки" = a0."DestinationAddress")
  • Heap Fetches: 0
21.          

CTE ext_t

22. 0.003 0.040 ↓ 0.0 0 1

Limit (cost=9,162.43..9,162.43 rows=1 width=175) (actual time=0.040..0.040 rows=0 loops=1)

23.          

Initplan (for Limit)

24. 0.001 0.006 ↑ 1.0 1 1

Limit (cost=0.02..0.02 rows=1 width=0) (actual time=0.006..0.006 rows=1 loops=1)

25. 0.005 0.005 ↓ 31.0 31 1

CTE Scan on pre_t pre_t_1 (cost=0.00..0.02 rows=1 width=0) (actual time=0.000..0.005 rows=31 loops=1)

26. 0.014 0.014 ↑ 1.0 1 1

CTE Scan on count_pre_t (cost=0.00..0.02 rows=1 width=8) (actual time=0.014..0.014 rows=1 loops=1)

27. 0.009 0.017 ↓ 0.0 0 1

Sort (cost=9,162.38..9,162.39 rows=1 width=175) (actual time=0.017..0.017 rows=0 loops=1)

  • Sort Key: "DT_2"."EndDateTime", "Д_2"."@Документ
  • Sort Method: quicksort Memory: 25kB
28. 0.008 0.008 ↓ 0.0 0 1

Result (cost=0.72..9,162.37 rows=1 width=175) (actual time=0.008..0.008 rows=0 loops=1)

  • One-Time Filter: (NOT $6)
29. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.72..9,162.37 rows=1 width=175) (never executed)

30. 0.000 0.000 ↓ 0.0 0

Nested Loop Left Join (cost=0.43..9,161.89 rows=1 width=179) (never executed)

  • Join Filter: ("DT_2"."@Документ" = a0_1."@Документ")
31. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.43..9,122.65 rows=1 width=179) (never executed)

32. 0.000 0.000 ↓ 0.0 0

Seq Scan on "DeliveryTask" "DT_2" (cost=0.00..25.77 rows=1,077 width=12) (never executed)

33. 0.000 0.000 ↓ 0.0 0

Index Scan using "pДокумент" on "Документ" "Д_2" (cost=0.43..8.44 rows=1 width=167) (never executed)

  • Index Cond: ("@Документ" = "DT_2"."@Документ")
  • Filter: (("Удален" IS NOT TRUE) AND ("ТипДокумента" IS NOT NULL) AND ("ТипДокумента" = ANY ('{4958,4790}'::integer[])) AND ("ДокументНашаОрганизация" IS DISTINCT FROM 22168590) AND (("$Черновик" IS NULL) OR ("$Черновик" = 10425562)))
34. 0.000 0.000 ↓ 0.0 0

Seq Scan on "DeliveryTask" a0_1 (cost=0.00..25.77 rows=1,077 width=8) (never executed)

35. 0.000 0.000 ↓ 0.0 0

Index Only Scan using "pАдресДоставки" on "АдресДоставки" addr_dt_1 (cost=0.28..0.48 rows=1 width=4) (never executed)

  • Index Cond: ("@АдресДоставки" = a0_1."DestinationAddress")
  • Heap Fetches: 0
36.          

CTE result

37. 0.019 6.010 ↓ 15.5 31 1

Unique (cost=0.07..0.21 rows=2 width=244) (actual time=5.990..6.010 rows=31 loops=1)

38. 0.043 5.991 ↓ 15.5 31 1

Sort (cost=0.07..0.08 rows=2 width=244) (actual time=5.989..5.991 rows=31 loops=1)

  • Sort Key: pre_t_2."@Документ", pre_t_2."ДокументНашаОрганизация", pre_t_2."Время", pre_t_2."Номер", pre_t_2."Дата", pre_t_2."ТипДокумента", pre_t_2."Лицо1", pre_t_2."Лицо2", pre_t_2."Лицо3", pre_t_2."ЛицоСоздал", pre_t_2."ЛицоИзменил", pre_t_2."Раздел", pre_t_2."Раздел@", pre_t_2."Документ_", pre_t_2."Примечание", pre_t_2."Сумма", pre_t_2."Сотрудник", pre_t_2."$Черновик", pre_t_2."Подразделение", pre_t_2."ИдентификаторДокумента", pre_t_2."Удален", pre_t_2."Лицо", pre_t_2."ЧисловойНомер", pre_t_2."ИдентификаторКаталога", pre_t_2."Пометки", pre_t_2."Регламент", pre_t_2."Лицо4
  • Sort Method: quicksort Memory: 31kB
39. 0.004 5.948 ↓ 15.5 31 1

Append (cost=0.00..0.06 rows=2 width=244) (actual time=5.880..5.948 rows=31 loops=1)

40. 5.903 5.903 ↓ 31.0 31 1

CTE Scan on pre_t pre_t_2 (cost=0.00..0.02 rows=1 width=244) (actual time=5.879..5.903 rows=31 loops=1)

41. 0.041 0.041 ↓ 0.0 0 1

CTE Scan on ext_t (cost=0.00..0.02 rows=1 width=244) (actual time=0.041..0.041 rows=0 loops=1)

42.          

CTE t

43. 0.047 6.099 ↓ 15.5 31 1

WindowAgg (cost=0.05..0.09 rows=2 width=244) (actual time=6.053..6.099 rows=31 loops=1)

44. 0.028 6.052 ↓ 15.5 31 1

Sort (cost=0.05..0.06 rows=2 width=244) (actual time=6.046..6.052 rows=31 loops=1)

  • Sort Key: result."Дата", result."@Документ
  • Sort Method: quicksort Memory: 31kB
45. 6.024 6.024 ↓ 15.5 31 1

CTE Scan on result (cost=0.00..0.04 rows=2 width=244) (actual time=5.992..6.024 rows=31 loops=1)

46. 0.349 8.845 ↑ 1.5 32 1

Nested Loop Left Join (cost=44.79..2,850.33 rows=48 width=1,750) (actual time=6.919..8.845 rows=32 loops=1)

47. 0.018 8.336 ↑ 1.5 32 1

Nested Loop Left Join (cost=44.36..2,042.13 rows=48 width=1,704) (actual time=6.845..8.336 rows=32 loops=1)

48. 0.032 8.254 ↑ 1.5 32 1

Nested Loop Left Join (cost=43.94..1,636.29 rows=48 width=1,658) (actual time=6.837..8.254 rows=32 loops=1)

49. 0.004 8.190 ↑ 1.5 32 1

Nested Loop Left Join (cost=43.51..1,230.45 rows=48 width=1,612) (actual time=6.832..8.190 rows=32 loops=1)

50. 0.033 8.090 ↑ 1.5 32 1

Nested Loop Left Join (cost=43.08..867.35 rows=48 width=1,546) (actual time=6.826..8.090 rows=32 loops=1)

51. 0.029 7.993 ↑ 1.5 32 1

Nested Loop Left Join (cost=42.65..504.26 rows=48 width=1,480) (actual time=6.814..7.993 rows=32 loops=1)

52. 0.018 7.900 ↑ 1.5 32 1

Nested Loop Left Join (cost=42.37..342.78 rows=48 width=1,167) (actual time=6.809..7.900 rows=32 loops=1)

53. 0.057 7.786 ↑ 1.5 32 1

Hash Left Join (cost=42.09..181.30 rows=48 width=854) (actual time=6.798..7.786 rows=32 loops=1)

  • Hash Cond: (t."@Документ" = dt."@Документ")
54. 0.037 7.091 ↑ 1.5 32 1

Nested Loop Left Join (cost=2.86..141.41 rows=48 width=694) (actual time=6.134..7.091 rows=32 loops=1)

55. 0.025 6.961 ↓ 15.5 31 1

Nested Loop Left Join (cost=2.43..101.22 rows=2 width=694) (actual time=6.119..6.961 rows=31 loops=1)

56. 0.020 6.874 ↓ 15.5 31 1

Nested Loop Left Join (cost=2.16..84.62 rows=2 width=589) (actual time=6.109..6.874 rows=31 loops=1)

57. 0.019 6.761 ↓ 15.5 31 1

Nested Loop Left Join (cost=1.73..67.72 rows=2 width=578) (actual time=6.099..6.761 rows=31 loops=1)

58. 0.034 6.649 ↓ 15.5 31 1

Nested Loop Left Join (cost=1.30..50.80 rows=2 width=521) (actual time=6.088..6.649 rows=31 loops=1)

59. 0.007 6.460 ↓ 15.5 31 1

Nested Loop Left Join (cost=0.86..33.88 rows=2 width=284) (actual time=6.077..6.460 rows=31 loops=1)

60. 0.012 6.329 ↓ 15.5 31 1

Nested Loop Left Join (cost=0.43..16.96 rows=2 width=235) (actual time=6.067..6.329 rows=31 loops=1)

61. 6.131 6.131 ↓ 15.5 31 1

CTE Scan on t (cost=0.00..0.04 rows=2 width=182) (actual time=6.055..6.131 rows=31 loops=1)

62. 0.186 0.186 ↑ 1.0 1 31

Index Scan using "pЛицо" on "Лицо" "Л1" (cost=0.43..8.45 rows=1 width=53) (actual time=0.005..0.006 rows=1 loops=31)

  • Index Cond: (t."Лицо1" = "@Лицо")
63. 0.124 0.124 ↑ 1.0 1 31

Index Scan using "pЛицо" on "Лицо" "ЛС" (cost=0.43..8.45 rows=1 width=49) (actual time=0.003..0.004 rows=1 loops=31)

  • Index Cond: (t."Сотрудник" = "@Лицо")
64. 0.155 0.155 ↑ 1.0 1 31

Index Scan using "pДокументРасширение" on "ДокументРасширение" "ДР" (cost=0.43..8.45 rows=1 width=241) (actual time=0.005..0.005 rows=1 loops=31)

  • Index Cond: (t."@Документ" = "@Документ")
65. 0.093 0.093 ↑ 1.0 1 31

Index Scan using "pКонтрагент" on "Контрагент" "КНО" (cost=0.43..8.45 rows=1 width=61) (actual time=0.003..0.003 rows=1 loops=31)

  • Index Cond: (t."ДокументНашаОрганизация" = "@Лицо")
66. 0.093 0.093 ↑ 1.0 1 31

Index Scan using "pКонтрагент" on "Контрагент" "К1" (cost=0.43..8.45 rows=1 width=15) (actual time=0.003..0.003 rows=1 loops=31)

  • Index Cond: (t."Лицо1" = "@Лицо")
67. 0.062 0.062 ↑ 1.0 1 31

Index Scan using "pТипДокумента" on "ТипДокумента" "ТД" (cost=0.27..8.29 rows=1 width=109) (actual time=0.002..0.002 rows=1 loops=31)

  • Index Cond: (t."ТипДокумента" = "@ТипДокумента")
68. 0.093 0.093 ↓ 0.0 0 31

Index Only Scan using "iSvyazDokumentov-DokumentOsnovanie" on "СвязьДокументов" "СВ" (cost=0.43..19.85 rows=24 width=4) (actual time=0.003..0.003 rows=0 loops=31)

  • Index Cond: ("ДокументОснование" = t."@Документ")
  • Heap Fetches: 12
69. 0.379 0.638 ↓ 1.0 1,092 1

Hash (cost=25.77..25.77 rows=1,077 width=164) (actual time=0.638..0.638 rows=1,092 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 116kB
70. 0.259 0.259 ↓ 1.0 1,092 1

Seq Scan on "DeliveryTask" dt (cost=0.00..25.77 rows=1,077 width=164) (actual time=0.006..0.259 rows=1,092 loops=1)

71. 0.096 0.096 ↑ 1.0 1 32

Index Scan using "pАдресДоставки" on "АдресДоставки" src (cost=0.28..3.35 rows=1 width=317) (actual time=0.003..0.003 rows=1 loops=32)

  • Index Cond: (dt."SourceAddress" = "@АдресДоставки")
72. 0.064 0.064 ↑ 1.0 1 32

Index Scan using "pАдресДоставки" on "АдресДоставки" dst (cost=0.28..3.35 rows=1 width=317) (actual time=0.002..0.002 rows=1 loops=32)

  • Index Cond: (dt."DestinationAddress" = "@АдресДоставки")
73. 0.064 0.064 ↑ 1.0 1 32

Index Scan using "pКонтрагент" on "Контрагент" sctr (cost=0.43..7.55 rows=1 width=70) (actual time=0.002..0.002 rows=1 loops=32)

  • Index Cond: (src."Лицо" = "@Лицо")
74. 0.096 0.096 ↑ 1.0 1 32

Index Scan using "pКонтрагент" on "Контрагент" dctr (cost=0.43..7.55 rows=1 width=70) (actual time=0.002..0.003 rows=1 loops=32)

  • Index Cond: (dst."Лицо" = "@Лицо")
75. 0.032 0.032 ↑ 1.0 1 32

Index Scan using "pКонтрагент" on "Контрагент" orgname (cost=0.43..8.45 rows=1 width=50) (actual time=0.001..0.001 rows=1 loops=32)

  • Index Cond: (t."Лицо2" = "@Лицо")
76. 0.064 0.064 ↑ 1.0 1 32

Index Scan using "pКонтрагент" on "Контрагент" depname (cost=0.43..8.45 rows=1 width=50) (actual time=0.001..0.002 rows=1 loops=32)

  • Index Cond: (t."Лицо3" = "@Лицо")
77. 0.032 0.032 ↑ 1.0 1 32

Index Scan using "pКонтрагент" on "Контрагент" face4 (cost=0.43..8.45 rows=1 width=50) (actual time=0.001..0.001 rows=1 loops=32)

  • Index Cond: (t."Лицо4" = "@Лицо")
78.          

SubPlan (for Nested Loop Left Join)

79. 0.032 0.128 ↑ 1.0 1 32

Limit (cost=0.29..8.30 rows=1 width=35) (actual time=0.004..0.004 rows=1 loops=32)

80. 0.096 0.096 ↑ 1.0 1 32

Index Scan using "iСтруктураПредприятия-Лицо" on "СтруктураПредприятия" sp (cost=0.29..8.30 rows=1 width=35) (actual time=0.003..0.003 rows=1 loops=32)

  • Index Cond: ("@Лицо" = t."Подразделение")
Planning time : 8.742 ms
Execution time : 10.220 ms