Re: BUG #19007: Planner fails to choose partial index with spurious 'not null'
От | Tom Lane |
---|---|
Тема | Re: BUG #19007: Planner fails to choose partial index with spurious 'not null' |
Дата | |
Msg-id | 516624.1754241580@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | BUG #19007: Planner fails to choose partial index with spurious 'not null' (PG Bug reporting form <noreply@postgresql.org>) |
Ответы |
Re: BUG #19007: Planner fails to choose partial index with spurious 'not null'
Re: BUG #19007: Planner fails to choose partial index with spurious 'not null' |
Список | pgsql-bugs |
PG Bug reporting form <noreply@postgresql.org> writes: > I'm not sure if this is a bug, but the behavior was unexpected to me and > changed since v16. Documentation doesn't mention this as far as I can see. > This example has a partial index over one column where another column is not > null. The latter column is in fact 'not null' in the schema. > Prior to v17, this index would be used; in v17, the planner will choose a > sequential scan instead. Yeah. What is happening is that the query's "flag is not null" condition is thrown away as redundant fairly early in planning, and then it's not available to match to the index's predicate, so the index doesn't appear to be applicable. I had thought that e2debb643 would fix this in HEAD, since it moved the throw-it-away behavior into eval_const_expressions which is also applied to index predicates. Testing shows not, which feels like a bug. It is not okay that eval_const_expressions' behavior varies depending on context; we need it to act the same on index expressions/predicates as on query expressions. Maybe we should give up on trying to pre-apply eval_const_expressions to the relcache's copies of the index expressions, and just do that part during plancat's collection of the info? (I'm also quite displeased that e2debb643 didn't nuke restriction_is_always_true/false. But that's a separate discussion.) regards, tom lane
В списке pgsql-bugs по дате отправления: