Thanks all, cursor resolved this problem. I thinked that queries are rewriten into implicit cursor, so I didn't use it for query. Now I see, I was wrong. Jirka Novak
pgsql-performance by date:
Соглашаюсь с условиями обработки персональных данных