Re: Complex filters -> Bad row estimates -> bad query plan
| От | Michael Lewis | 
|---|---|
| Тема | Re: Complex filters -> Bad row estimates -> bad query plan | 
| Дата | |
| Msg-id | CAHOFxGoQffz1bxmJi=R31f5xNiA4+rMOcUoQL8re43NwPVuFSA@mail.gmail.com обсуждение исходный текст | 
| Ответ на | Complex filters -> Bad row estimates -> bad query plan (Mathieu Fenniak <mathieu.fenniak@replicon.com>) | 
| Ответы | Re: Complex filters -> Bad row estimates -> bad query plan | 
| Список | pgsql-general | 
If those conditions that are throwing off the stats are expected to be minimally impactful/filtering few rows, then you can use the one tried-and-true optimizer hint (aside from materialized CTEs, stylized indexes, etc) --- OFFSET 0 at the end of a sub-query.
If there is correlation between field1 and field2, you might also look at CREATE STATISTICS assuming you are on PG 10 or 11.
Before I do any of that, I would try LEFT JOIN for Table3 and Table4 then use the where conditon  "AND 2 = COALESCE( Table3.Status, Table4.Status" and see if the optimizer likes that option better.
В списке pgsql-general по дате отправления: