From: Tom Lane <tgl@sss.pgh.pa.us>
To: Samuel Williams <space.ship.traveller@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Partial index on JSON column
Date: Tue, 19 Feb 2019 16:14:37 -0500
Message-ID: <31590.1550610877@sss.pgh.pa.us> (raw)
In-Reply-To: <CAHkN8V9Rfh6uAjQLURJfnHsQfC_MYiFUSWEVcwVSiPdokmkniw@mail.gmail.com>
References: <CAHkN8V9Rfh6uAjQLURJfnHsQfC_MYiFUSWEVcwVSiPdokmkniw@mail.gmail.com>
Samuel Williams <space.ship.traveller@gmail.com> writes:
> When I do this query:
> EXPLAIN SELECT COUNT(*) FROM "user_event" WHERE ((parameters ->>
> 'suggestion_id'::text)::integer = 26) AND what = 'suggestion_notification';
> It's slow. I need to explicitly add the NULL constraint:
Try it like
EXPLAIN SELECT COUNT(*) FROM "user_event" WHERE ((parameters ->>
'suggestion_id'::text) = '26') AND what = 'suggestion_notification';
I don't think we assume that CoerceViaIO is strict, and without that
the deduction that the value couldn't be null doesn't hold. In any
case you're better off without the runtime type conversion: that
isn't doing much for you except raising the odds of getting an error.
regards, tom lane
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: tgl@sss.pgh.pa.us, space.ship.traveller@gmail.com
Subject: Re: Partial index on JSON column
In-Reply-To: <31590.1550610877@sss.pgh.pa.us>
References: <CAHkN8V9Rfh6uAjQLURJfnHsQfC_MYiFUSWEVcwVSiPdokmkniw@mail.gmail.com> <31590.1550610877@sss.pgh.pa.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