Original query:

"Nested Loop Left Join  (cost=45.87..160.24 rows=2 width=980) (actual time=10.491..10.920 rows=2 loops=1)"
"  ->  Hash Left Join  (cost=45.59..143.61 rows=2 width=692) (actual time=10.467..10.886 rows=2 loops=1)"
"        Hash Cond: ((doks.kto)::text = (pracbv.login)::text)"
"        ->  Nested Loop Left Join  (cost=2.11..100.10 rows=2 width=677) (actual time=8.528..8.943 rows=2 loops=1)"
"              ->  Nested Loop Left Join  (cost=1.69..83.19 rows=2 width=666) (actual time=8.488..8.881 rows=2 loops=1)"
"                    ->  Nested Loop Left Join  (cost=1.28..66.28 rows=2 width=648) (actual time=8.453..8.821 rows=2 loops=1)"
"                          ->  Nested Loop Left Join  (cost=1.00..49.64 rows=2 width=634) (actual time=8.401..8.736 rows=2 loops=1)"
"                                ->  Nested Loop Left Join  (cost=0.71..33.00 rows=2 width=542) (actual time=8.363..8.677 rows=2 loops=1)"
"                                      ->  Index Scan using doks_rowid on doks  (cost=0.42..16.37 rows=2 width=403) (actual time=0.035..0.061 rows=2 loops=1)"
"                                            Index Cond: (rowid = ANY ('{1,2}'::integer[]))"
"                                      ->  Index Scan using pk_kh on kh  (cost=0.29..8.31 rows=1 width=139) (actual time=4.291..4.293 rows=1 loops=2)"
"                                            Index Cond: (((doks.kart_plat)::text = (kod_kart)::text) AND (doks.platnik = kod))"
"                                ->  Index Scan using pk_kh on kh odb  (cost=0.29..8.31 rows=1 width=92) (actual time=0.014..0.015 rows=1 loops=2)"
"                                      Index Cond: (((doks.kart_plat)::text = (kod_kart)::text) AND (doks.odbiorca = kod))"
"                          ->  Index Scan using doks_fak_kor on doks kor  (cost=0.28..8.31 rows=1 width=36) (actual time=0.029..0.029 rows=0 loops=2)"
"                                Index Cond: ((oddz = doks.oddz) AND (dzial = doks.dzial) AND ((mag)::text = (doks.mag)::text) AND ((doks.typ_dok)::text = (typ_fak_kor)::text) AND ((doks.nr_dok)::text = (nr_fak_kor)::text))"
"                    ->  Index Scan using doks_dok_ref on doks pa  (cost=0.41..8.45 rows=1 width=40) (actual time=0.021..0.021 rows=0 loops=2)"
"                          Index Cond: ((oddz = doks.oddz) AND (dzial = doks.dzial) AND ((mag)::text = (doks.mag)::text) AND ((doks.typ_dok)::text = (typ_dok_ref)::text) AND ((doks.nr_dok)::text = (nr_dok_ref)::text))"
"                          Filter: ((typ_dok)::text = CASE WHEN ((doks.typ_dok)::text = 'FV'::text) THEN 'PA'::text ELSE 'PAEU'::text END)"
"              ->  Index Scan using doks_dok_ref on doks tax  (cost=0.41..8.44 rows=1 width=30) (actual time=0.017..0.017 rows=0 loops=2)"
"                    Index Cond: ((oddz = doks.oddz) AND (dzial = doks.dzial) AND ((mag)::text = (doks.mag)::text) AND ((typ_dok_ref)::text = 'PA'::text) AND ((nr_dok_ref)::text = (doks.nr_dok)::text))"
"        ->  Hash  (cost=41.56..41.56 rows=154 width=20) (actual time=1.907..1.907 rows=61 loops=1)"
"              Buckets: 1024  Batches: 1  Memory Usage: 7kB"
"              ->  Subquery Scan on pracbv  (cost=37.45..41.56 rows=154 width=20) (actual time=1.393..1.849 rows=96 loops=1)"
"                    ->  Unique  (cost=37.45..40.02 rows=154 width=246) (actual time=1.391..1.783 rows=96 loops=1)"
"                          ->  Sort  (cost=37.45..38.74 rows=513 width=246) (actual time=1.389..1.583 rows=512 loops=1)"
"                                Sort Key: pracownicy.kod_pracow, pracownicy.tz DESC"
"                                Sort Method: quicksort  Memory: 53kB"
"                                ->  Seq Scan on pracownicy  (cost=0.00..14.36 rows=513 width=246) (actual time=0.027..0.514 rows=512 loops=1)"
"                                      Filter: (kod_pracow < 100)"
"                                      Rows Removed by Filter: 77"
"  ->  Index Scan using tab_kurs_rowid on tab_kurs  (cost=0.28..8.30 rows=1 width=28) (actual time=0.001..0.001 rows=0 loops=2)"
"        Index Cond: (doks.kursv_id = rowid)"
"Planning time: 48.764 ms"
"Execution time: 12.458 ms"