Other alternatives worth reading about: RESET work_mem SET LOCAL work_mem
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных