Re: BUG #14107: Major query planner bug regarding subqueries and indices
От | Tom Lane |
---|---|
Тема | Re: BUG #14107: Major query planner bug regarding subqueries and indices |
Дата | |
Msg-id | 18635.1461892238@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: BUG #14107: Major query planner bug regarding subqueries and indices (Mathias Kunter <mathiaskunter@gmail.com>) |
Ответы |
Re: BUG #14107: Major query planner bug regarding subqueries
and indices
Re: BUG #14107: Major query planner bug regarding subqueries and indices Re: BUG #14107: Major query planner bug regarding subqueries and indices |
Список | pgsql-bugs |
Mathias Kunter <mathiaskunter@gmail.com> writes: > Does anybody care? Shouldn't something like this be fixed ASAP?? As was already stated upthread, this is not a bug; it's an opportunity for future improvement. It's unlikely to get "fixed ASAP" because there would be quite a bit of work involved, possibly including new executor infrastructure not just planner work. As far as the first case goes, the executor doesn't currently have any direct way to treat "a.x IN (SELECT ...)" as an indexqual for a.x. In simple cases the planner can work around that by transforming the query into a join against a unique-ified version of the sub-select, but that doesn't work if the IN is underneath an OR. If you know that the sub-select isn't going to return very many rows, you could do SELECT ... FROM a WHERE a.x = ? OR a.y = ANY(ARRAY(SELECT ...)); but this would blow up rather badly with a large sub-select result, so I'm not sure I want to try to make the planner transform it that way automatically. I don't actually see any way to do very much with your second example at all: > SELECT ... FROM a JOIN b ON (...) WHERE a.x = ? OR b.y = ?; There's no way to push anything down to either the A or B scans from that WHERE condition: you can't remove any rows before the join because they might join to rows on the other side that satisfy the other half of the OR. regards, tom lane
В списке pgsql-bugs по дате отправления: