In fact it seems it's no planner's mistake, you would need for some indexing how is the table layout, and what indexes u have?
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных