From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
Cc: | Josh Berkus <josh(at)agliodbs(dot)com>, Tim Dudgeon <tdudgeon(dot)ml(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Re: [SQL] querying with index on jsonb slower than standard column. Why? |
Date: | 2014-12-13 01:20:37 |
Message-ID: | 15863.1418433637@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance pgsql-sql |
Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> On 12/12/2014 04:44 PM, Tom Lane wrote:
>> Well, it'd be easy to fix if we were willing to invent distinct operators
>> depending on which type you wanted out (perhaps ->> for text output as
>> today, add ->># for numeric output, etc).
> That was my immediate reaction. Not sure about the operator name. I'd
> tentatively suggest -># (taking an int or text argument) and #># taking
> a text[] argument, both returning numeric, and erroring out if the value
> is a string, boolean, object or array.
>> The usability issue could be fixed by teaching the planner to fold a
>> construct like (jsonb ->> 'foo')::numeric into (jsonb ->># 'foo').
>> But I'm not sure how we do that except in a really ugly and ad-hoc
>> fashion.
> I would be inclined to add the operator and see how cumbersome people
> find it. I suspect in many cases it might be sufficient.
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.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2014-12-13 03:05:20 | Re: Re: [SQL] querying with index on jsonb slower than standard column. Why? |
Previous Message | Andrew Dunstan | 2014-12-12 23:27:31 | Re: Re: [SQL] querying with index on jsonb slower than standard column. Why? |
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2014-12-13 03:05:20 | Re: Re: [SQL] querying with index on jsonb slower than standard column. Why? |
Previous Message | Andrew Dunstan | 2014-12-12 23:27:31 | Re: Re: [SQL] querying with index on jsonb slower than standard column. Why? |