explain.depesz.com

PostgreSQL's explain analyze made readable

Result: G5l8N

Settings
# exclusive inclusive rows x rows loops node
1. 0.328 7.734 ↓ 15.5 31 1

Sort (cost=27,675.38..27,675.39 rows=2 width=1,750) (actual time=7.733..7.734 rows=31 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: 82kB
2.          

CTE pre_t

3. 0.005 5.412 ↓ 31.0 31 1

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

4. 0.479 5.407 ↓ 31.0 31 1

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

  • Sort Key: "DT"."EndDateTime", "Д"."@Документ
  • Sort Method: top-N heapsort Memory: 32kB
5. 0.284 4.928 ↓ 843.0 843 1

Nested Loop (cost=0.43..9,122.65 rows=1 width=175) (actual time=0.024..4.928 rows=843 loops=1)

6. 0.284 0.284 ↓ 1.0 1,090 1

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

7. 4.360 4.360 ↑ 1.0 1 1,090

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

  • 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.013 ↑ 1.0 1 1

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

10.          

Initplan (for Aggregate)

11. 0.003 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.003 0.003 ↓ 31.0 31 1

CTE Scan on pre_t (cost=0.00..0.02 rows=1 width=0) (actual time=0.001..0.003 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.002 0.043 ↓ 0.0 0 1

Limit (cost=9,162.43..9,162.43 rows=1 width=175) (actual time=0.043..0.043 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.001..0.005 rows=31 loops=1)

26. 0.013 0.013 ↑ 1.0 1 1

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

27. 0.015 0.022 ↓ 0.0 0 1

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

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

Result (cost=0.72..9,162.37 rows=1 width=175) (actual time=0.007..0.007 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.017 5.530 ↓ 15.5 31 1

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

38. 0.032 5.513 ↓ 15.5 31 1

Sort (cost=0.07..0.08 rows=2 width=244) (actual time=5.512..5.513 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.005 5.481 ↓ 15.5 31 1

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

40. 5.433 5.433 ↓ 31.0 31 1

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

41. 0.043 0.043 ↓ 0.0 0 1

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

42.          

CTE t

43. 0.038 5.602 ↓ 15.5 31 1

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

44. 0.019 5.564 ↓ 15.5 31 1

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

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

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

46. 0.355 7.406 ↓ 15.5 31 1

Nested Loop Left Join (cost=5.40..227.56 rows=2 width=1,750) (actual time=5.734..7.406 rows=31 loops=1)

47. 0.011 6.927 ↓ 15.5 31 1

Nested Loop Left Join (cost=4.98..193.88 rows=2 width=1,704) (actual time=5.677..6.927 rows=31 loops=1)

48. 0.031 6.854 ↓ 15.5 31 1

Nested Loop Left Join (cost=4.55..176.97 rows=2 width=1,658) (actual time=5.668..6.854 rows=31 loops=1)

49. 0.006 6.792 ↓ 15.5 31 1

Nested Loop Left Join (cost=4.12..160.06 rows=2 width=1,612) (actual time=5.664..6.792 rows=31 loops=1)

50. 0.021 6.724 ↓ 15.5 31 1

Nested Loop Left Join (cost=3.69..144.94 rows=2 width=1,546) (actual time=5.655..6.724 rows=31 loops=1)

51. 0.016 6.641 ↓ 15.5 31 1

Nested Loop Left Join (cost=3.27..129.81 rows=2 width=1,480) (actual time=5.646..6.641 rows=31 loops=1)

52. 0.027 6.563 ↓ 15.5 31 1

Nested Loop Left Join (cost=2.99..123.82 rows=2 width=1,167) (actual time=5.642..6.563 rows=31 loops=1)

53. 0.034 6.474 ↓ 15.5 31 1

Nested Loop Left Join (cost=2.71..117.83 rows=2 width=854) (actual time=5.633..6.474 rows=31 loops=1)

54. 0.020 6.378 ↓ 15.5 31 1

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

55. 0.004 6.296 ↓ 15.5 31 1

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

56. 0.017 6.199 ↓ 15.5 31 1

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

57. 0.035 6.089 ↓ 15.5 31 1

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

58. 0.032 5.930 ↓ 15.5 31 1

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

59. 0.044 5.805 ↓ 15.5 31 1

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

60. 5.637 5.637 ↓ 15.5 31 1

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

61. 0.124 0.124 ↑ 1.0 1 31

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

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

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

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

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

  • Index Cond: (t."@Документ" = "@Документ")
64. 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.002..0.003 rows=1 loops=31)

  • Index Cond: (t."ДокументНашаОрганизация" = "@Лицо")
65. 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.002..0.003 rows=1 loops=31)

  • Index Cond: (t."Лицо1" = "@Лицо")
66. 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."ТипДокумента" = "@ТипДокумента")
67. 0.062 0.062 ↑ 1.0 1 31

Index Scan using "pDeliveryTask" on "DeliveryTask" dt (cost=0.28..8.29 rows=1 width=164) (actual time=0.002..0.002 rows=1 loops=31)

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

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

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

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

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

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

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

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

  • Index Cond: (dst."Лицо" = "@Лицо")
72. 0.031 0.031 ↑ 1.0 1 31

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

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

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

  • Index Cond: (t."Лицо3" = "@Лицо")
74. 0.031 0.031 ↑ 1.0 1 31

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

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

SubPlan (for Nested Loop Left Join)

76. 0.031 0.093 ↑ 1.0 1 31

Limit (cost=0.29..8.30 rows=1 width=35) (actual time=0.003..0.003 rows=1 loops=31)

77. 0.062 0.062 ↑ 1.0 1 31

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

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