explain.depesz.com

PostgreSQL's explain analyze made readable

Result: vk7B : Optimization for: plan #aTQB

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1,501.60..1,807,517.05 rows=22,265 width=1,873) (actual rows= loops=)

  • Join Filter: (a.id_kontrahenta = aa.id_kontrahenta)
2. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=37.22..1,245,374.17 rows=22,265 width=1,665) (actual rows= loops=)

  • Join Filter: (btrim((i.kraj)::text) = btrim(dg.sprawdz_kraj(a.id_kontrahenta)))
3. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=37.22..31,826.60 rows=18,632 width=1,544) (actual rows= loops=)

  • Hash Cond: (a.kto = g.id_uzytkownika)
4. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=8.09..31,541.28 rows=18,632 width=1,483) (actual rows= loops=)

  • Hash Cond: (a.id_grupy_cennik = f.id)
5. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=6.59..31,285.44 rows=18,632 width=1,382) (actual rows= loops=)

  • Hash Cond: (a.grupa_rabatowa = e.id_grupy)
6. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=2.95..31,043.59 rows=18,632 width=1,331) (actual rows= loops=)

  • Hash Cond: (a.id_rodzaju3 = d.id_rodzaju)
7. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1.66..30,821.05 rows=18,632 width=1,290) (actual rows= loops=)

  • Hash Cond: (a.id_rodzaju1 = b.id_rodzaju)
8. 0.000 0.000 ↓ 0.0

Merge Right Join (cost=0.54..30,595.05 rows=18,632 width=1,249) (actual rows= loops=)

  • Merge Cond: (c.id_rodzaju = a.id_rodzaju2)
9. 0.000 0.000 ↓ 0.0

Index Scan using spd_rk2_auto on spd_kontrahenci_rodzaje2 c (cost=0.13..6.21 rows=5 width=45) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Index Scan using spd_kon_f_rodzaj2 on spd_kontrahenci a (cost=0.41..30,457.56 rows=18,632 width=1,208) (actual rows= loops=)

11. 0.000 0.000 ↓ 0.0

Hash (cost=1.05..1.05 rows=5 width=45) (actual rows= loops=)

12. 0.000 0.000 ↓ 0.0

Seq Scan on spd_kontrahenci_rodzaje1 b (cost=0.00..1.05 rows=5 width=45) (actual rows= loops=)

13. 0.000 0.000 ↓ 0.0

Hash (cost=1.13..1.13 rows=13 width=45) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

Seq Scan on spd_kontrahenci_rodzaje3 d (cost=0.00..1.13 rows=13 width=45) (actual rows= loops=)

15. 0.000 0.000 ↓ 0.0

Hash (cost=2.73..2.73 rows=73 width=55) (actual rows= loops=)

16. 0.000 0.000 ↓ 0.0

Seq Scan on spd_kontrahenci_grupy_rabatow e (cost=0.00..2.73 rows=73 width=55) (actual rows= loops=)

17. 0.000 0.000 ↓ 0.0

Hash (cost=1.22..1.22 rows=22 width=105) (actual rows= loops=)

18. 0.000 0.000 ↓ 0.0

Seq Scan on spd_grupy_cennikowe f (cost=0.00..1.22 rows=22 width=105) (actual rows= loops=)

19. 0.000 0.000 ↓ 0.0

Hash (cost=25.17..25.17 rows=317 width=65) (actual rows= loops=)

20. 0.000 0.000 ↓ 0.0

Seq Scan on adm_uzytkownicy g (cost=0.00..25.17 rows=317 width=65) (actual rows= loops=)

21. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..92.58 rows=239 width=142) (actual rows= loops=)

22. 0.000 0.000 ↓ 0.0

Seq Scan on spd_kraje i (cost=0.00..91.39 rows=239 width=142) (actual rows= loops=)

23. 0.000 0.000 ↓ 0.0

Materialize (cost=1,464.38..2,869.82 rows=13 width=212) (actual rows= loops=)

24. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1,464.38..2,869.75 rows=13 width=212) (actual rows= loops=)

25. 0.000 0.000 ↓ 0.0

Hash Join (cost=1,464.24..2,867.57 rows=13 width=8) (actual rows= loops=)

  • Hash Cond: ((spd_kontrahenci_hand.id_kontrahenta = aa.id_kontrahenta) AND ((max(spd_kontrahenci_hand.od_kiedy)) = aa.od_kiedy))
26. 0.000 0.000 ↓ 0.0

HashAggregate (cost=593.59..733.91 rows=14,032 width=8) (actual rows= loops=)

27. 0.000 0.000 ↓ 0.0

Seq Scan on spd_kontrahenci_hand (cost=0.00..455.06 rows=27,706 width=8) (actual rows= loops=)

28. 0.000 0.000 ↓ 0.0

Hash (cost=455.06..455.06 rows=27,706 width=12) (actual rows= loops=)

29. 0.000 0.000 ↓ 0.0

Seq Scan on spd_kontrahenci_hand aa (cost=0.00..455.06 rows=27,706 width=12) (actual rows= loops=)

30. 0.000 0.000 ↓ 0.0

Index Scan using spd_han_auto on spd_handlowcy bb (cost=0.14..0.16 rows=1 width=208) (actual rows= loops=)

  • Index Cond: (aa.id_handlowca = kod)
31.          

SubPlan (for Nested Loop Left Join)

32. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=2.87..15.04 rows=1 width=259) (actual rows= loops=)

33. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=2.73..14.72 rows=1 width=208) (actual rows= loops=)

34. 0.000 0.000 ↓ 0.0

Nested Loop (cost=2.59..10.55 rows=1 width=4) (actual rows= loops=)

  • Join Filter: (r.od_kiedy = (max(spd_kontrahenci_hand_1.od_kiedy)))
35. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=0.29..4.35 rows=2 width=8) (actual rows= loops=)

36. 0.000 0.000 ↓ 0.0

Index Only Scan using spd_hak_auto on spd_kontrahenci_hand spd_kontrahenci_hand_1 (cost=0.29..4.32 rows=2 width=8) (actual rows= loops=)

  • Index Cond: (id_kontrahenta = a.id_platnika)
37. 0.000 0.000 ↓ 0.0

Materialize (cost=2.30..6.13 rows=2 width=12) (actual rows= loops=)

38. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on spd_kontrahenci_hand r (cost=2.30..6.12 rows=2 width=12) (actual rows= loops=)

  • Recheck Cond: (id_kontrahenta = a.id_platnika)
39. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on spd_hak_auto (cost=0.00..2.30 rows=2 width=0) (actual rows= loops=)

  • Index Cond: (id_kontrahenta = a.id_platnika)
40. 0.000 0.000 ↓ 0.0

Index Scan using spd_han_auto on spd_handlowcy s (cost=0.14..4.16 rows=1 width=212) (actual rows= loops=)

  • Index Cond: (r.id_handlowca = kod)
41. 0.000 0.000 ↓ 0.0

Index Scan using spd_hsi_auto on spd_handlowcy_sieci t (cost=0.14..0.28 rows=1 width=55) (actual rows= loops=)

  • Index Cond: (s.id_sieci = id)
42. 0.000 0.000 ↓ 0.0

Index Scan using spd_kin_sort_kontrahent on spd_kontrahenci_info_dodatkow (cost=0.42..4.44 rows=1 width=4) (actual rows= loops=)

  • Index Cond: ((id_kontrahenta = a.id_kontrahenta) AND (rodzaj_info = 1))
43. 0.000 0.000 ↓ 0.0

Index Scan using spd_kin_sort_kontrahent on spd_kontrahenci_info_dodatkow spd_kontrahenci_info_dodatkow_1 (cost=0.42..4.44 rows=1 width=254) (actual rows= loops=)

  • Index Cond: ((id_kontrahenta = a.id_kontrahenta) AND (rodzaj_info = 75))