Re: Unused expression indexes

2024-08-07 Thread Maciek Sakrejda
Great, thank you both for the info.

Re: Unused expression indexes

2024-08-06 Thread Tomas Vondra
On 8/6/24 22:25, Tom Lane wrote: > Maciek Sakrejda writes: >> In a blog post [1], Bruce Momjian notes that expression indexes can >> help with planning even if they're not used directly. But the examples >> cited in that post are vague (i.e., they improve stats, but it's not >> clear how they coul

Re: Unused expression indexes

2024-08-06 Thread Tom Lane
Maciek Sakrejda writes: > Thanks, but I was asking specifically about _unused_ indexes > (according to pg_stat_user_indexes). Bruce's blog post showed how they > can still influence rowcount estimates, but can they do that (1) even > if they don't end up being used by the query plan and (2) in a w

Re: Unused expression indexes

2024-08-06 Thread Maciek Sakrejda
On Tue, Aug 6, 2024 at 1:25 PM Tom Lane wrote: > The planner has no info about the values of sqrt(x1), so you get a > default estimate (one-third) of the selectivity of the WHERE clause. > But watch this: > > regression=# create index on foo (sqrt(x1)); > CREATE INDEX > regression=# analyze foo; >

Re: Unused expression indexes

2024-08-06 Thread Tom Lane
Maciek Sakrejda writes: > In a blog post [1], Bruce Momjian notes that expression indexes can > help with planning even if they're not used directly. But the examples > cited in that post are vague (i.e., they improve stats, but it's not > clear how they could change plans), and Bruce's answer to