explain.depesz.com

A tool for finding a real cause for slow queries.

Result: P5V

options
Did it help? Consider supporting us - Bitcoin address: 12v2hUztAk2LgzQ9H9LMwuU32urHMjZQnq
# exclusive inclusive rows x rows loops node
1. 364.977 262,340.939 ↑ 1.0 1 1

Aggregate (cost=1,162,186.27..1,162,186.28 rows=1 width=0) (actual time=262,340.938..262,340.939 rows=1 loops=1)

2. 5,186.340 261,975.962 ↓ 5.2 271,582 1

Sort (cost=1,161,409.65..1,161,539.08 rows=51,775 width=628) (actual time=260,931.116..261,975.962 rows=271,582 loops=1)

  • Sort Key: cl.lastname
3. 6,683.437 256,789.622 ↓ 5.2 271,582 1

Hash Left Join (cost=1,098,790.31..1,142,666.17 rows=51,775 width=628) (actual time=218,695.885..256,789.622 rows=271,582 loops=1)

  • Hash Cond: (ct.contact_next_type = dv8.id)
  • Filter: (((((u.name = 'cc'::text) AND (ur.name <> 'cc'::text)) OR ((lst_act.value ~~ 'spotkanie odby_o si_'::text) AND ((slp.date IS NULL) OR (slp.date < ct.contact_next_date))) OR ((lst_act.value ~~ '%zarejestrowano wizyt_%'::text) AND ct.is_meeting_happened AND prt.perform_surveys) OR ((NOT ct.is_confirmed_meeting) AND (ct.last_meeting_not_happened_date IS NOT NULL) AND ((lst_act.value ~~ 'zmieniono dat_/typ spotkania'::text) OR (lst_act.value ~~ 'wype_niono formularz 33'::text)))) AND (ct.contact_next_date <> '1970-01-01 01:00:00+01'::timestamp with time zone) AND ((ctc.contact_date <= ct.contact_date) OR (ctc_next_tp.value !~~ 'telefon'::text)) AND (dv8.value ~~* 'spotkanie'::text)) OR (lst_act.value ~~ 'spotkanie nie odby_o si_'::text) OR (lst_act.value ~~ 'nie potwierdzono spotkania'::text) OR ct.is_survey OR (ct.is_survey2 AND ((((date_part('day'::text, (now() - (ct.last_survey_date)::timestamp with time zone)))::integer >= 30) AND (prt.name = 'Kredyt hipoteczny'::text)) OR (((date_part('day'::text, (now() - (ct.last_survey_date)::timestamp with time zone)))::integer >= 14) AND (prt.name = 'Lokata'::text)) OR (((date_part('day'::text, (now() - (ct.last_survey_date)::timestamp with time zone)))::integer >= 14) AND (prt.name = 'Emerytura'::text)) OR (((date_part('day'::text, (now() - (ct.last_survey_date)::timestamp with time zone)))::integer >= 10) AND (prt.name = 'Kredyt gotĂłwkowy'::text)))) OR (((date_part('day'::text, (now() - (ct.last_meeting_date)::timestamp with time zone)))::integer >= 30) AND (prt.name = 'Kredyt hipoteczny'::text)) OR (((date_part('day'::text, (now() - (ct.last_meeting_date)::timestamp with time zone)))::integer >= 14) AND (prt.name = 'Lokata'::text)) OR (((date_part('day'::text, (now() - (ct.last_meeting_date)::timestamp with time zone)))::integer >= 14) AND (prt.name = 'Emerytura'::text)) OR (((date_part('day'::text, (now() - (ct.last_meeting_date)::timestamp with time zone)))::integer >= 10) AND (prt.name = 'Kredyt gotĂłwkowy'::text)))
4. 3,648.040 250,095.072 ↓ 2.2 1,102,267 1

Hash Left Join (cost=1,098,676.83..1,114,714.98 rows=507,983 width=703) (actual time=218,684.678..250,095.072 rows=1,102,267 loops=1)

  • Hash Cond: (ct.last_action = lst_act.id)
5. 3,358.565 246,436.688 ↓ 2.2 1,102,267 1

Hash Left Join (cost=1,098,563.34..1,106,907.92 rows=507,983 width=678) (actual time=218,674.302..246,436.688 rows=1,102,267 loops=1)

  • Hash Cond: (ctc.contact_next_type = ctc_next_tp.id)
6. 3,445.004 242,950.512 ↓ 2.2 1,102,267 1

Merge Left Join (cost=1,098,449.86..1,102,835.55 rows=507,983 width=653) (actual time=218,546.647..242,950.512 rows=1,102,267 loops=1)

  • Merge Cond: (cl.id = slp.id_client)
7. 4,924.072 238,482.004 ↓ 2.2 1,102,267 1

Merge Left Join (cost=1,093,443.74..1,096,260.36 rows=507,983 width=653) (actual time=217,578.296..238,482.004 rows=1,102,267 loops=1)

  • Merge Cond: (cl.id = rej_visit.id)
  • Filter: ((cl.client_type = 1) OR ((cl.client_type = 2) AND ((rej_visit.date_reg <= (now() - '6 mons'::interval)) OR (rej_visit.date_reg IS NULL) OR ct.is_survey)))
8. 26,905.369 232,246.853 ↓ 2.2 1,104,410 1

Sort (cost=1,087,884.51..1,089,163.86 rows=511,741 width=645) (actual time=216,314.443..232,246.853 rows=1,104,410 loops=1)

  • Sort Key: cl.id
9. 3,810.706 205,341.484 ↓ 2.2 1,104,410 1

Hash Left Join (cost=499,566.49..890,682.03 rows=511,741 width=645) (actual time=76,385.692..205,341.484 rows=1,104,410 loops=1)

  • Hash Cond: (ct.contact_status = dv1.id)
10. 3,744.734 201,519.972 ↓ 2.2 1,104,410 1

Hash Left Join (cost=499,453.01..882,773.19 rows=511,741 width=612) (actual time=76,374.861..201,519.972 rows=1,104,410 loops=1)

  • Hash Cond: (ct.client_classification = dv2.id)
11. 3,749.033 197,765.086 ↓ 2.2 1,104,410 1

Hash Left Join (cost=499,339.52..876,365.63 rows=511,741 width=579) (actual time=76,364.684..197,765.086 rows=1,104,410 loops=1)

  • Hash Cond: (ct.end_status = dv3.id)
12. 3,785.097 194,005.936 ↓ 2.2 1,104,410 1

Hash Left Join (cost=499,226.04..869,755.43 rows=511,741 width=546) (actual time=76,354.539..194,005.936 rows=1,104,410 loops=1)

  • Hash Cond: (ctc.contact_status = dv4.id)
13. 3,752.043 190,210.666 ↓ 2.2 1,104,410 1

Hash Left Join (cost=499,112.55..861,846.59 rows=511,741 width=521) (actual time=76,344.340..190,210.666 rows=1,104,410 loops=1)

  • Hash Cond: (ctc.end_status = dv5.id)
14. 3,767.396 186,447.942 ↓ 2.2 1,104,410 1

Hash Left Join (cost=498,999.07..855,236.38 rows=511,741 width=496) (actual time=76,333.634..186,447.942 rows=1,104,410 loops=1)

  • Hash Cond: (cl.client_type = dv6.id)
15. 3,526.296 182,670.303 ↓ 2.2 1,104,410 1

Hash Left Join (cost=498,885.58..846,807.11 rows=511,741 width=463) (actual time=76,323.363..182,670.303 rows=1,104,410 loops=1)

  • Hash Cond: (ct.prefered_contact_time = dv7.id)
16. 3,600.341 179,096.416 ↓ 2.2 1,104,410 1

Hash Left Join (cost=498,772.10..841,511.22 rows=511,741 width=438) (actual time=76,275.752..179,096.416 rows=1,104,410 loops=1)

  • Hash Cond: (ct.id_unit_responsible = ur.id)
17. 3,926.497 175,482.433 ↓ 2.2 1,104,410 1

Hash Left Join (cost=498,758.90..835,814.28 rows=511,741 width=421) (actual time=76,262.090..175,482.433 rows=1,104,410 loops=1)

  • Hash Cond: (ctc.id_consultant_responsible = w.id)
18. 3,655.847 171,543.807 ↓ 2.2 1,104,410 1

Hash Left Join (cost=498,591.21..829,981.62 rows=511,741 width=399) (actual time=76,249.931..171,543.807 rows=1,104,410 loops=1)

  • Hash Cond: (cl.id_main_consultant_cc = w_main.id)
19. 26,162.114 167,834.881 ↓ 2.2 1,104,410 1

Hash Left Join (cost=498,423.51..825,146.17 rows=511,741 width=377) (actual time=76,196.825..167,834.881 rows=1,104,410 loops=1)

  • Hash Cond: (cl.id_last_contact_cc = ctc.id)
20. 33,718.219 113,585.969 ↓ 2.2 1,104,410 1

Hash Join (cost=259,770.01..492,559.87 rows=511,741 width=329) (actual time=48,091.122..113,585.969 rows=1,104,410 loops=1)

  • Hash Cond: (cl.id_last_contact_unit = ct.id)
21. 31,787.202 31,787.202 ↓ 1.1 1,471,644 1

Seq Scan on client cl (cost=0.00..129,625.36 rows=1,339,017 width=115) (actual time=10.238..31,787.202 rows=1,471,644 loops=1)

  • Filter: ((client_type = 1) OR (client_type = 2))
22. 6,707.692 48,080.548 ↓ 1.8 2,311,697 1

Hash (cost=201,951.27..201,951.27 rows=1,292,699 width=230) (actual time=48,080.548..48,080.548 rows=2,311,697 loops=1)

23. 7,209.612 41,372.856 ↓ 1.8 2,311,697 1

Hash Join (cost=14.52..201,951.27 rows=1,292,699 width=230) (actual time=29.963..41,372.856 rows=2,311,697 loops=1)

  • Hash Cond: (ct.id_unit_register = u.id)
24. 9,211.062 34,147.610 ↓ 1.7 2,530,028 1

Hash Join (cost=1.32..183,316.04 rows=1,518,678 width=221) (actual time=14.316..34,147.610 rows=2,530,028 loops=1)

  • Hash Cond: (ct.id_product_type_main = prt.id)
25. 24,934.280 24,934.280 ↑ 1.1 2,819,629 1

Seq Scan on last_contact ct (cost=0.00..156,733.67 rows=3,038,470 width=188) (actual time=12.032..24,934.280 rows=2,819,629 loops=1)

  • Filter: (contact_status IS NOT NULL)
26. 0.025 2.268 ↑ 1.0 10 1

Hash (cost=1.20..1.20 rows=10 width=41) (actual time=2.268..2.268 rows=10 loops=1)

27. 2.243 2.243 ↑ 1.0 10 1

Seq Scan on product_type prt (cost=0.00..1.20 rows=10 width=41) (actual time=2.222..2.243 rows=10 loops=1)

  • Filter: visible_in_meetingscc
28. 0.516 15.634 ↑ 1.0 320 1

Hash (cost=9.20..9.20 rows=320 width=25) (actual time=15.634..15.634 rows=320 loops=1)

29. 15.118 15.118 ↑ 1.0 320 1

Seq Scan on unit u (cost=0.00..9.20 rows=320 width=25) (actual time=4.541..15.118 rows=320 loops=1)

30. 6,220.188 28,086.798 ↑ 1.1 3,129,246 1

Hash (cost=156,733.67..156,733.67 rows=3,382,467 width=64) (actual time=28,086.798..28,086.798 rows=3,129,246 loops=1)

31. 21,866.610 21,866.610 ↑ 1.1 3,129,246 1

Seq Scan on last_contact ctc (cost=0.00..156,733.67 rows=3,382,467 width=64) (actual time=9.080..21,866.610 rows=3,129,246 loops=1)

32. 5.977 53.079 ↑ 1.0 3,417 1

Hash (cost=124.53..124.53 rows=3,453 width=30) (actual time=53.079..53.079 rows=3,417 loops=1)

33. 47.102 47.102 ↑ 1.0 3,417 1

Seq Scan on worker w_main (cost=0.00..124.53 rows=3,453 width=30) (actual time=5.518..47.102 rows=3,417 loops=1)

34. 6.419 12.129 ↑ 1.0 3,417 1

Hash (cost=124.53..124.53 rows=3,453 width=38) (actual time=12.129..12.129 rows=3,417 loops=1)

35. 5.710 5.710 ↑ 1.0 3,417 1

Seq Scan on worker w (cost=0.00..124.53 rows=3,453 width=38) (actual time=0.005..5.710 rows=3,417 loops=1)

36. 0.511 13.642 ↑ 1.0 320 1

Hash (cost=9.20..9.20 rows=320 width=25) (actual time=13.642..13.642 rows=320 loops=1)

37. 13.131 13.131 ↑ 1.0 320 1

Seq Scan on unit ur (cost=0.00..9.20 rows=320 width=25) (actual time=2.547..13.131 rows=320 loops=1)

38. 5.465 47.591 ↓ 1.0 3,268 1

Hash (cost=72.66..72.66 rows=3,266 width=41) (actual time=47.591..47.591 rows=3,268 loops=1)

39. 42.126 42.126 ↓ 1.0 3,268 1

Seq Scan on dictionaryvalue dv7 (cost=0.00..72.66 rows=3,266 width=41) (actual time=10.912..42.126 rows=3,268 loops=1)

40. 5.396 10.243 ↓ 1.0 3,268 1

Hash (cost=72.66..72.66 rows=3,266 width=41) (actual time=10.243..10.243 rows=3,268 loops=1)

41. 4.847 4.847 ↓ 1.0 3,268 1

Seq Scan on dictionaryvalue dv6 (cost=0.00..72.66 rows=3,266 width=41) (actual time=0.006..4.847 rows=3,268 loops=1)

42. 5.938 10.681 ↓ 1.0 3,268 1

Hash (cost=72.66..72.66 rows=3,266 width=41) (actual time=10.681..10.681 rows=3,268 loops=1)

43. 4.743 4.743 ↓ 1.0 3,268 1

Seq Scan on dictionaryvalue dv5 (cost=0.00..72.66 rows=3,266 width=41) (actual time=0.006..4.743 rows=3,268 loops=1)

44. 5.488 10.173 ↓ 1.0 3,268 1

Hash (cost=72.66..72.66 rows=3,266 width=41) (actual time=10.173..10.173 rows=3,268 loops=1)

45. 4.685 4.685 ↓ 1.0 3,268 1

Seq Scan on dictionaryvalue dv4 (cost=0.00..72.66 rows=3,266 width=41) (actual time=0.006..4.685 rows=3,268 loops=1)

46. 5.437 10.117 ↓ 1.0 3,268 1

Hash (cost=72.66..72.66 rows=3,266 width=41) (actual time=10.117..10.117 rows=3,268 loops=1)

47. 4.680 4.680 ↓ 1.0 3,268 1

Seq Scan on dictionaryvalue dv3 (cost=0.00..72.66 rows=3,266 width=41) (actual time=0.006..4.680 rows=3,268 loops=1)

48. 5.465 10.152 ↓ 1.0 3,268 1

Hash (cost=72.66..72.66 rows=3,266 width=41) (actual time=10.152..10.152 rows=3,268 loops=1)

49. 4.687 4.687 ↓ 1.0 3,268 1

Seq Scan on dictionaryvalue dv2 (cost=0.00..72.66 rows=3,266 width=41) (actual time=0.006..4.687 rows=3,268 loops=1)

50. 5.808 10.806 ↓ 1.0 3,268 1

Hash (cost=72.66..72.66 rows=3,266 width=41) (actual time=10.806..10.806 rows=3,268 loops=1)

51. 4.998 4.998 ↓ 1.0 3,268 1

Seq Scan on dictionaryvalue dv1 (cost=0.00..72.66 rows=3,266 width=41) (actual time=0.006..4.998 rows=3,268 loops=1)

52. 99.833 1,311.079 ↓ 1.6 32,676 1

Sort (cost=5,559.23..5,609.57 rows=20,134 width=16) (actual time=1,263.809..1,311.079 rows=32,676 loops=1)

  • Sort Key: rej_visit.id
53. 90.764 1,211.246 ↓ 1.6 32,676 1

Subquery Scan rej_visit (cost=3,767.57..4,119.92 rows=20,134 width=16) (actual time=981.999..1,211.246 rows=32,676 loops=1)

54. 92.988 1,120.482 ↓ 1.6 32,676 1

Unique (cost=3,767.57..3,918.58 rows=20,134 width=16) (actual time=981.994..1,120.482 rows=32,676 loops=1)

55. 115.291 1,027.494 ↓ 1.6 32,676 1

Sort (cost=3,767.57..3,817.91 rows=20,134 width=16) (actual time=981.989..1,027.494 rows=32,676 loops=1)

  • Sort Key: id, max(date)
56. 140.469 912.203 ↓ 1.6 32,676 1

HashAggregate (cost=2,076.58..2,328.26 rows=20,134 width=16) (actual time=857.902..912.203 rows=32,676 loops=1)

57. 771.734 771.734 ↓ 1.5 43,324 1

Seq Scan on unit (cost=0.00..1,931.99 rows=28,918 width=16) (actual time=57.713..771.734 rows=43,324 loops=1)

  • Filter: (form = ANY ('{190,200,210,220,230,231,240,250,251,280,290,300,310}'::integer[]))
58. 139.514 1,023.504 ↓ 1.0 36,096 1

Sort (cost=5,006.12..5,094.66 rows=35,415 width=16) (actual time=968.338..1,023.504 rows=36,096 loops=1)

  • Sort Key: slp.id_client
59. 143.657 883.990 ↓ 1.0 36,096 1

HashAggregate (cost=1,533.32..1,976.00 rows=35,415 width=16) (actual time=818.161..883.990 rows=36,096 loops=1)

60. 740.333 740.333 ↑ 1.0 38,810 1

Seq Scan on satisfaction_level_pool (cost=0.00..1,339.25 rows=38,813 width=16) (actual time=29.116..740.333 rows=38,810 loops=1)

  • Filter: (answer_1 IS NOT NULL)
61. 5.342 127.611 ↓ 1.0 3,268 1

Hash (cost=72.66..72.66 rows=3,266 width=41) (actual time=127.611..127.611 rows=3,268 loops=1)

62. 122.269 122.269 ↓ 1.0 3,268 1

Seq Scan on dictionaryvalue ctc_next_tp (cost=0.00..72.66 rows=3,266 width=41) (actual time=33.910..122.269 rows=3,268 loops=1)

63. 5.619 10.344 ↓ 1.0 3,268 1

Hash (cost=72.66..72.66 rows=3,266 width=41) (actual time=10.344..10.344 rows=3,268 loops=1)

64. 4.725 4.725 ↓ 1.0 3,268 1

Seq Scan on dictionaryvalue lst_act (cost=0.00..72.66 rows=3,266 width=41) (actual time=0.009..4.725 rows=3,268 loops=1)

65. 5.394 11.113 ↓ 1.0 3,268 1

Hash (cost=72.66..72.66 rows=3,266 width=41) (actual time=11.113..11.113 rows=3,268 loops=1)

66. 5.719 5.719 ↓ 1.0 3,268 1

Seq Scan on dictionaryvalue dv8 (cost=0.00..72.66 rows=3,266 width=41) (actual time=0.007..5.719 rows=3,268 loops=1)