I went to 2.4 seconds by joining first the tables that produce many rows.
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных