Re: surprising query optimisation - Mailing list pgsql-general

From Stephen Frost
Subject Re: surprising query optimisation
Date
Msg-id 20181205143340.GB3415@tamriel.snowman.net
Whole thread Raw
In response to Re: surprising query optimisation  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-general
Greetings,

* Thomas Kellerer (spam_eater@gmx.net) wrote:
> Stephen Frost schrieb am 30.11.2018 um 14:05:
> > PG doesn’t know, with complete certainty, that there’s only 3
> > values.
>
> Would the optimizer consult a check constraint ensuring that?

Not today, I don't believe (haven't looked at the code though, to be
fair), and seems like it'd be an awful lot of work for a rare
use-case that would be better with just a partial index..

What we will do today is if you ask for a specific value and there's a
CHECK constraint which lists out specific values and that value isn't
among the set, then we'll just skip over the table (One-time filter:
false), thanks to constraint exclusion.

Thanks!

Stephen

Attachment

pgsql-general by date:

Previous
From: Dejan Petrovic
Date:
Subject: Database corruption in cascaded replica, "pg_xact/003A" doesn'texist, reading as zeroes"
Next
From: Chris Withers
Date:
Subject: debugging intermittent slow updates under higher load