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 262340.939 ↑ 1.0 1 1

Aggregate (cost=1162186.27..1162186.28 rows=1 width=0) (actual time=262340.938..262340.939 rows=1 loops=1)

2. 5186.340 261975.962 ↓ 5.2 271582 1

Sort (cost=1161409.65..1161539.08 rows=51775 width=628) (actual time=260931.116..261975.962 rows=271582 loops=1)

  • Sort Key: cl.lastname
3. 6683.437 256789.622 ↓ 5.2 271582 1

Hash Left Join (cost=1098790.31..1142666.17 rows=51775 width=628) (actual time=218695.885..256789.622 rows=271582 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. 3648.040 250095.072 ↓ 2.2 1102267 1

Hash Left Join (cost=1098676.83..1114714.98 rows=507983 width=703) (actual time=218684.678..250095.072 rows=1102267 loops=1)

  • Hash Cond: (ct.last_action = lst_act.id)
5. 3358.565 246436.688 ↓ 2.2 1102267 1

Hash Left Join (cost=1098563.34..1106907.92 rows=507983 width=678) (actual time=218674.302..246436.688 rows=1102267 loops=1)

  • Hash Cond: (ctc.contact_next_type = ctc_next_tp.id)
6. 3445.004 242950.512 ↓ 2.2 1102267 1

Merge Left Join (cost=1098449.86..1102835.55 rows=507983 width=653) (actual time=218546.647..242950.512 rows=1102267 loops=1)

  • Merge Cond: (cl.id = slp.id_client)
7. 4924.072 238482.004 ↓ 2.2 1102267 1

Merge Left Join (cost=1093443.74..1096260.36 rows=507983 width=653) (actual time=217578.296..238482.004 rows=1102267 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. 26905.369 232246.853 ↓ 2.2 1104410 1

Sort (cost=1087884.51..1089163.86 rows=511741 width=645) (actual time=216314.443..232246.853 rows=1104410 loops=1)

  • Sort Key: cl.id
9. 3810.706 205341.484 ↓ 2.2 1104410 1

Hash Left Join (cost=499566.49..890682.03 rows=511741 width=645) (actual time=76385.692..205341.484 rows=1104410 loops=1)

  • Hash Cond: (ct.contact_status = dv1.id)
10. 3744.734 201519.972 ↓ 2.2 1104410 1

Hash Left Join (cost=499453.01..882773.19 rows=511741 width=612) (actual time=76374.861..201519.972 rows=1104410 loops=1)

  • Hash Cond: (ct.client_classification = dv2.id)
11. 3749.033 197765.086 ↓ 2.2 1104410 1

Hash Left Join (cost=499339.52..876365.63 rows=511741 width=579) (actual time=76364.684..197765.086 rows=1104410 loops=1)

  • Hash Cond: (ct.end_status = dv3.id)
12. 3785.097 194005.936 ↓ 2.2 1104410 1

Hash Left Join (cost=499226.04..869755.43 rows=511741 width=546) (actual time=76354.539..194005.936 rows=1104410 loops=1)

  • Hash Cond: (ctc.contact_status = dv4.id)
13. 3752.043 190210.666 ↓ 2.2 1104410 1

Hash Left Join (cost=499112.55..861846.59 rows=511741 width=521) (actual time=76344.340..190210.666 rows=1104410 loops=1)

  • Hash Cond: (ctc.end_status = dv5.id)
14. 3767.396 186447.942 ↓ 2.2 1104410 1

Hash Left Join (cost=498999.07..855236.38 rows=511741 width=496) (actual time=76333.634..186447.942 rows=1104410 loops=1)

  • Hash Cond: (cl.client_type = dv6.id)
15. 3526.296 182670.303 ↓ 2.2 1104410 1

Hash Left Join (cost=498885.58..846807.11 rows=511741 width=463) (actual time=76323.363..182670.303 rows=1104410 loops=1)

  • Hash Cond: (ct.prefered_contact_time = dv7.id)
16. 3600.341 179096.416 ↓ 2.2 1104410 1

Hash Left Join (cost=498772.10..841511.22 rows=511741 width=438) (actual time=76275.752..179096.416 rows=1104410 loops=1)

  • Hash Cond: (ct.id_unit_responsible = ur.id)
17. 3926.497 175482.433 ↓ 2.2 1104410 1

Hash Left Join (cost=498758.90..835814.28 rows=511741 width=421) (actual time=76262.090..175482.433 rows=1104410 loops=1)

  • Hash Cond: (ctc.id_consultant_responsible = w.id)
18. 3655.847 171543.807 ↓ 2.2 1104410 1

Hash Left Join (cost=498591.21..829981.62 rows=511741 width=399) (actual time=76249.931..171543.807 rows=1104410 loops=1)

  • Hash Cond: (cl.id_main_consultant_cc = w_main.id)
19. 26162.114 167834.881 ↓ 2.2 1104410 1

Hash Left Join (cost=498423.51..825146.17 rows=511741 width=377) (actual time=76196.825..167834.881 rows=1104410 loops=1)

  • Hash Cond: (cl.id_last_contact_cc = ctc.id)
20. 33718.219 113585.969 ↓ 2.2 1104410 1

Hash Join (cost=259770.01..492559.87 rows=511741 width=329) (actual time=48091.122..113585.969 rows=1104410 loops=1)

  • Hash Cond: (cl.id_last_contact_unit = ct.id)
21. 31787.202 31787.202 ↓ 1.1 1471644 1

Seq Scan on client cl (cost=0.00..129625.36 rows=1339017 width=115) (actual time=10.238..31787.202 rows=1471644 loops=1)

  • Filter: ((client_type = 1) OR (client_type = 2))
22. 6707.692 48080.548 ↓ 1.8 2311697 1

Hash (cost=201951.27..201951.27 rows=1292699 width=230) (actual time=48080.548..48080.548 rows=2311697 loops=1)

23. 7209.612 41372.856 ↓ 1.8 2311697 1

Hash Join (cost=14.52..201951.27 rows=1292699 width=230) (actual time=29.963..41372.856 rows=2311697 loops=1)

  • Hash Cond: (ct.id_unit_register = u.id)
24. 9211.062 34147.610 ↓ 1.7 2530028 1

Hash Join (cost=1.32..183316.04 rows=1518678 width=221) (actual time=14.316..34147.610 rows=2530028 loops=1)

  • Hash Cond: (ct.id_product_type_main = prt.id)
25. 24934.280 24934.280 ↑ 1.1 2819629 1

Seq Scan on last_contact ct (cost=0.00..156733.67 rows=3038470 width=188) (actual time=12.032..24934.280 rows=2819629 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. 6220.188 28086.798 ↑ 1.1 3129246 1

Hash (cost=156733.67..156733.67 rows=3382467 width=64) (actual time=28086.798..28086.798 rows=3129246 loops=1)

31. 21866.610 21866.610 ↑ 1.1 3129246 1

Seq Scan on last_contact ctc (cost=0.00..156733.67 rows=3382467 width=64) (actual time=9.080..21866.610 rows=3129246 loops=1)

32. 5.977 53.079 ↑ 1.0 3417 1

Hash (cost=124.53..124.53 rows=3453 width=30) (actual time=53.079..53.079 rows=3417 loops=1)

33. 47.102 47.102 ↑ 1.0 3417 1

Seq Scan on worker w_main (cost=0.00..124.53 rows=3453 width=30) (actual time=5.518..47.102 rows=3417 loops=1)

34. 6.419 12.129 ↑ 1.0 3417 1

Hash (cost=124.53..124.53 rows=3453 width=38) (actual time=12.129..12.129 rows=3417 loops=1)

35. 5.710 5.710 ↑ 1.0 3417 1

Seq Scan on worker w (cost=0.00..124.53 rows=3453 width=38) (actual time=0.005..5.710 rows=3417 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 3268 1

Hash (cost=72.66..72.66 rows=3266 width=41) (actual time=47.591..47.591 rows=3268 loops=1)

39. 42.126 42.126 ↓ 1.0 3268 1

Seq Scan on dictionaryvalue dv7 (cost=0.00..72.66 rows=3266 width=41) (actual time=10.912..42.126 rows=3268 loops=1)

40. 5.396 10.243 ↓ 1.0 3268 1

Hash (cost=72.66..72.66 rows=3266 width=41) (actual time=10.243..10.243 rows=3268 loops=1)

41. 4.847 4.847 ↓ 1.0 3268 1

Seq Scan on dictionaryvalue dv6 (cost=0.00..72.66 rows=3266 width=41) (actual time=0.006..4.847 rows=3268 loops=1)

42. 5.938 10.681 ↓ 1.0 3268 1

Hash (cost=72.66..72.66 rows=3266 width=41) (actual time=10.681..10.681 rows=3268 loops=1)

43. 4.743 4.743 ↓ 1.0 3268 1

Seq Scan on dictionaryvalue dv5 (cost=0.00..72.66 rows=3266 width=41) (actual time=0.006..4.743 rows=3268 loops=1)

44. 5.488 10.173 ↓ 1.0 3268 1

Hash (cost=72.66..72.66 rows=3266 width=41) (actual time=10.173..10.173 rows=3268 loops=1)

45. 4.685 4.685 ↓ 1.0 3268 1

Seq Scan on dictionaryvalue dv4 (cost=0.00..72.66 rows=3266 width=41) (actual time=0.006..4.685 rows=3268 loops=1)

46. 5.437 10.117 ↓ 1.0 3268 1

Hash (cost=72.66..72.66 rows=3266 width=41) (actual time=10.117..10.117 rows=3268 loops=1)

47. 4.680 4.680 ↓ 1.0 3268 1

Seq Scan on dictionaryvalue dv3 (cost=0.00..72.66 rows=3266 width=41) (actual time=0.006..4.680 rows=3268 loops=1)

48. 5.465 10.152 ↓ 1.0 3268 1

Hash (cost=72.66..72.66 rows=3266 width=41) (actual time=10.152..10.152 rows=3268 loops=1)

49. 4.687 4.687 ↓ 1.0 3268 1

Seq Scan on dictionaryvalue dv2 (cost=0.00..72.66 rows=3266 width=41) (actual time=0.006..4.687 rows=3268 loops=1)

50. 5.808 10.806 ↓ 1.0 3268 1

Hash (cost=72.66..72.66 rows=3266 width=41) (actual time=10.806..10.806 rows=3268 loops=1)

51. 4.998 4.998 ↓ 1.0 3268 1

Seq Scan on dictionaryvalue dv1 (cost=0.00..72.66 rows=3266 width=41) (actual time=0.006..4.998 rows=3268 loops=1)

52. 99.833 1311.079 ↓ 1.6 32676 1

Sort (cost=5559.23..5609.57 rows=20134 width=16) (actual time=1263.809..1311.079 rows=32676 loops=1)

  • Sort Key: rej_visit.id
53. 90.764 1211.246 ↓ 1.6 32676 1

Subquery Scan rej_visit (cost=3767.57..4119.92 rows=20134 width=16) (actual time=981.999..1211.246 rows=32676 loops=1)

54. 92.988 1120.482 ↓ 1.6 32676 1

Unique (cost=3767.57..3918.58 rows=20134 width=16) (actual time=981.994..1120.482 rows=32676 loops=1)

55. 115.291 1027.494 ↓ 1.6 32676 1

Sort (cost=3767.57..3817.91 rows=20134 width=16) (actual time=981.989..1027.494 rows=32676 loops=1)

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

HashAggregate (cost=2076.58..2328.26 rows=20134 width=16) (actual time=857.902..912.203 rows=32676 loops=1)

57. 771.734 771.734 ↓ 1.5 43324 1

Seq Scan on unit (cost=0.00..1931.99 rows=28918 width=16) (actual time=57.713..771.734 rows=43324 loops=1)

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

Sort (cost=5006.12..5094.66 rows=35415 width=16) (actual time=968.338..1023.504 rows=36096 loops=1)

  • Sort Key: slp.id_client
59. 143.657 883.990 ↓ 1.0 36096 1

HashAggregate (cost=1533.32..1976.00 rows=35415 width=16) (actual time=818.161..883.990 rows=36096 loops=1)

60. 740.333 740.333 ↑ 1.0 38810 1

Seq Scan on satisfaction_level_pool (cost=0.00..1339.25 rows=38813 width=16) (actual time=29.116..740.333 rows=38810 loops=1)

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

Hash (cost=72.66..72.66 rows=3266 width=41) (actual time=127.611..127.611 rows=3268 loops=1)

62. 122.269 122.269 ↓ 1.0 3268 1

Seq Scan on dictionaryvalue ctc_next_tp (cost=0.00..72.66 rows=3266 width=41) (actual time=33.910..122.269 rows=3268 loops=1)

63. 5.619 10.344 ↓ 1.0 3268 1

Hash (cost=72.66..72.66 rows=3266 width=41) (actual time=10.344..10.344 rows=3268 loops=1)

64. 4.725 4.725 ↓ 1.0 3268 1

Seq Scan on dictionaryvalue lst_act (cost=0.00..72.66 rows=3266 width=41) (actual time=0.009..4.725 rows=3268 loops=1)

65. 5.394 11.113 ↓ 1.0 3268 1

Hash (cost=72.66..72.66 rows=3266 width=41) (actual time=11.113..11.113 rows=3268 loops=1)

66. 5.719 5.719 ↓ 1.0 3268 1

Seq Scan on dictionaryvalue dv8 (cost=0.00..72.66 rows=3266 width=41) (actual time=0.007..5.719 rows=3268 loops=1)