The weird thing is that before I updated my server the query was about 5 times faster.
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных