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