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

From: Claudio Freire <klaussfreire(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: 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: [PERFORM] Re: querying with index on jsonb slower than standard column. Why?
Date: 2014-12-12 22:10:29
Message-ID: CAGTBQpZDYYF+UYgFQrKUutGk1pHJ2i0m7DS8sgte0GyZf7A8tg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance pgsql-sql

On Fri, Dec 12, 2014 at 6:44 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> 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.

It would be doable if you could have polymorphism on return type, and
teach the planner to interpret (jsonb ->> 'foo')::numeric as the
operator with a numeric return type.

That's a trickier business even, but it could be far more useful and
generically helpful than ->>#.

Tricky part is what to do when the cast is missing.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Andrew Dunstan 2014-12-12 23:27:31 Re: Re: [SQL] querying with index on jsonb slower than standard column. Why?
Previous Message Tom Lane 2014-12-12 21:44:10 Re: Re: [SQL] querying with index on jsonb slower than standard column. Why?

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Dunstan 2014-12-12 23:27:31 Re: Re: [SQL] querying with index on jsonb slower than standard column. Why?
Previous Message Tom Lane 2014-12-12 21:44:10 Re: Re: [SQL] querying with index on jsonb slower than standard column. Why?