Re: Partial index on JSON column - Mailing list pgsql-general

From Tom Lane
Subject Re: Partial index on JSON column
Date
Msg-id 31590.1550610877@sss.pgh.pa.us
Whole thread Raw
In response to Partial index on JSON column  (Samuel Williams <space.ship.traveller@gmail.com>)
Responses Re: Partial index on JSON column  (Samuel Williams <space.ship.traveller@gmail.com>)
Re: Partial index on JSON column  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
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


pgsql-general by date:

Previous
From: Reid Thompson
Date:
Subject: PG 9.6 managed fail over of master, how do i manage a pg_logicalsubscriber
Next
From: Samuel Williams
Date:
Subject: Re: Partial index on JSON column