Tomasz Myrta <jasiek(at)klaster(dot)net> writes:
> If I add "and k.id_trasy=lt.id_trasy" into where clause (duplicate), the
> query works fine.
Define "works fine", please (again, EXPLAIN ANALYZE would be a nice
concrete description).
regards, tom lane