pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Koen De Groote <kdg.dev@gmail.com>
Cc: Michael Lewis <mlewis@entrata.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: Re: Index no longer being used, destroying and recreating it restores use.
Date: Tue, 16 Jun 2020 06:00:38 -0400
Message-ID: <20200616100038.GA31183@momjian.us> (raw)
In-Reply-To: <CAGbX52H_zRZFJwGurV9b+=0JHJmY-4Xrh16UqbQrsiiQ09WSoQ@mail.gmail.com>
References: <CAGbX52GzwrgBZNhpSGEYwob5NiVjz=_6_OB14oXTjdFu-9mO4A@mail.gmail.com>
	<92ea007a-abe0-1dd2-7e5c-080da70c2e2c@aklaver.com>
	<CAGbX52FSLneL7U7bdm5hpY6MTxY30tPBE08uGoezWPaZRjLh0A@mail.gmail.com>
	<CAHOFxGo6W9O9qfNk_CQ4vQ=1SFyi6R5+DyM-mpwmjSUZWPGudg@mail.gmail.com>
	<CAGbX52G_OvW0Z7C7-gWucL+iypaJh-x9zcG6FkB7K0oCsnZ1oA@mail.gmail.com>
	<CAGbX52FKg9a+GDds8j34VSeEBy0mXAeK75u-6ufHX6sTBPTsFg@mail.gmail.com>
	<CAHOFxGqS8yTOoQSg61eo7xsj=qQYewMBvqYJmc9Mw0Swwwmr6g@mail.gmail.com>
	<CAGbX52EA+cfT06Wg0u3OUVP_jzsFzbrbfHvpmogPVBiXk6Jo_A@mail.gmail.com>
	<CAHOFxGqAV58PYCtmZt6Kfcw-f44Nyf2KahtFGZL3OCAB8snS2g@mail.gmail.com>
	<CAGbX52H_zRZFJwGurV9b+=0JHJmY-4Xrh16UqbQrsiiQ09WSoQ@mail.gmail.com>

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






view thread (17+ messages)

Message-ID: <20200616100038.GA31183@momjian.us>
Permalink:  ../20200616100038.GA31183@momjian.us/
Also on:    postgresql.org/message-id/20200616100038.GA31183@momjian.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: bruce@momjian.us, kdg.dev@gmail.com, mlewis@entrata.com, adrian.klaver@aklaver.com, tgl@sss.pgh.pa.us
  Subject: Re: Index no longer being used, destroying and recreating it restores use.
  In-Reply-To: <20200616100038.GA31183@momjian.us>
  References: <CAGbX52GzwrgBZNhpSGEYwob5NiVjz=_6_OB14oXTjdFu-9mO4A@mail.gmail.com> <92ea007a-abe0-1dd2-7e5c-080da70c2e2c@aklaver.com> <CAGbX52FSLneL7U7bdm5hpY6MTxY30tPBE08uGoezWPaZRjLh0A@mail.gmail.com> <CAHOFxGo6W9O9qfNk_CQ4vQ=1SFyi6R5+DyM-mpwmjSUZWPGudg@mail.gmail.com> <CAGbX52G_OvW0Z7C7-gWucL+iypaJh-x9zcG6FkB7K0oCsnZ1oA@mail.gmail.com> <CAGbX52FKg9a+GDds8j34VSeEBy0mXAeK75u-6ufHX6sTBPTsFg@mail.gmail.com> <CAHOFxGqS8yTOoQSg61eo7xsj=qQYewMBvqYJmc9Mw0Swwwmr6g@mail.gmail.com> <CAGbX52EA+cfT06Wg0u3OUVP_jzsFzbrbfHvpmogPVBiXk6Jo_A@mail.gmail.com> <CAHOFxGqAV58PYCtmZt6Kfcw-f44Nyf2KahtFGZL3OCAB8snS2g@mail.gmail.com> <CAGbX52H_zRZFJwGurV9b+=0JHJmY-4Xrh16UqbQrsiiQ09WSoQ@mail.gmail.com> <20200616100038.GA31183@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox