Re: Re: [SQL] querying with index on jsonb slower than standard column. Why?

From: Claudio Freire <klaussfreire(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Josh Berkus <josh(at)agliodbs(dot)com>, Tim Dudgeon <tdudgeon(dot)ml(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org, postgres performance list <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Re: [SQL] querying with index on jsonb slower than standard column. Why?
Date: 2014-12-13 05:38:41
Message-ID: CAGTBQpYb_yUV5Gy5UXn2tpmrnzn0CwCa5ifKYp1Z-8qRbDiu6A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance pgsql-sql

On Sat, Dec 13, 2014 at 12:05 AM, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
> On 12/12/2014 08:20 PM, Tom Lane wrote:
>>
>> We can't just add the operator and worry about usability later;
>> if we're thinking we might want to introduce such an automatic
>> transformation, we have to be sure the new operator is defined in a
>> way that allows the transformation to not change any semantics.
>> What that means in this case is that if (jsonb ->> 'foo')::numeric
>> would have succeeded, (jsonb ->># 'foo') has to succeed; which means
>> it'd better be willing to attempt conversion of string values to
>> numeric, not just throw an error on sight.
>>
>>
>
>
> Well, I'm not 100% convinced about the magic transformation being a good
> thing.
>
> Json numbers are distinct from strings, and part of the justification for
> this is to extract a numeric datum from jsonb exactly as stored, on
> performance grounds. So turning round now and making that turn a string into
> a number if possible seems to me to be going in the wrong direction.

It's still better than doing the conversion every time. The niceness
of that implementation aside, I don't see how it can be considered the
wrong direction.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Graeme B. Bell 2014-12-15 13:36:45 Re: Tuning the configuration
Previous Message Andrew Dunstan 2014-12-13 03:05:20 Re: Re: [SQL] querying with index on jsonb slower than standard column. Why?

Browse pgsql-sql by date

  From Date Subject
Next Message Ed Rahn 2014-12-14 09:13:45 foregin table insert error
Previous Message Andrew Dunstan 2014-12-13 03:05:20 Re: Re: [SQL] querying with index on jsonb slower than standard column. Why?