Re: Index-only scan for "f(x)" without "x"

2020-01-22 Thread Malthe
On Thu, 23 Jan 2020 at 00:00, Tom Lane wrote: > The problem is that the planner's initial analysis of the query tree > concludes that the scan of "tab" has to return "x", because it looks > through the tree for plain Vars, and "x" is what it's going to find. > This conclusion is in fact true for a

Re: Index-only scan for "f(x)" without "x"

2020-01-22 Thread Tom Lane
Malthe writes: > Referencing the example given in the documentation for index-only > scans [0], we consider an index: > CREATE INDEX tab_f_x ON tab (f(x)); > This index currently will not be used for an index-scan for the > following query since the planner isn't smart enough to know that "x" > is

Index-only scan for "f(x)" without "x"

2020-01-22 Thread Malthe
Referencing the example given in the documentation for index-only scans [0], we consider an index: CREATE INDEX tab_f_x ON tab (f(x)); This index currently will not be used for an index-scan for the following query since the planner isn't smart enough to know that "x" is not needed: SELECT f(x)