Re: Unused expression indexes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Maciek Sakrejda <maciek(at)pganalyze(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Unused expression indexes
Date: 2024-08-06 21:03:54
Message-ID: 1832687.1722978234@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Maciek Sakrejda <maciek(at)pganalyze(dot)com> 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 way
> that leads to a different plan?

Certainly. This example was too simple to illustrate that point
perhaps, but we would have arrived at the same rowcount estimate
whether it then chose to use the index or not. (You could prove
that with the same example by modifying the comparison constant
to make the rowcount estimate high enough to discourage use of
the index.) In turn, a different rowcount estimate might change
the plan for subsequent joins or other processing. I didn't
spend enough time on the example to show that, but it's surely
not hard to show.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2024-08-06 21:20:25 Re: Unused expression indexes
Previous Message Maciek Sakrejda 2024-08-06 20:53:31 Re: Unused expression indexes