Re: Index no longer being used, destroying and recreating itrestores use. - Mailing list pgsql-general

From Bruce Momjian
Subject Re: Index no longer being used, destroying and recreating itrestores use.
Date
Msg-id 20200616100038.GA31183@momjian.us
Whole thread Raw
In response to Re: Index no longer being used, destroying and recreating it restores use.  (Koen De Groote <kdg.dev@gmail.com>)
List pgsql-general
On Tue, Jun 16, 2020 at 11:49:15AM +0200, Koen De Groote wrote:
> Alright, I've done that, and that seems to be a very good result: https://
> explain.depesz.com/s/xIph
> 
> The method I ended up using:
> 
> create or replace function still_needs_backup(shouldbebackedup bool,
> backupperformed bool)
> returns BOOLEAN as $$
>    select $1 AND NOT $2;
> $$
> language sql immutable;
> 
> And the index is as suggested.
> 
> It seems the amount of rows we end up with has improved.
> 
> Thank you for your help. I wasn't aware functions could interact with indexes
> in such a manner.

This blog entry explains how statistics on expression/function indexes
can help:

    https://momjian.us/main/blogs/pgblog/2017.html#February_20_2017

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EnterpriseDB                             https://enterprisedb.com

  The usefulness of a cup is in its emptiness, Bruce Lee




pgsql-general by date:

Previous
From: Koen De Groote
Date:
Subject: Re: Index no longer being used, destroying and recreating it restores use.
Next
From: Eugene Pazhitnov
Date:
Subject: pg_repack: WARNING: relation must have a primary key or not-nullunique keys