Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XzY0g-0008DM-ML for pgsql-performance@arkaria.postgresql.org; Fri, 12 Dec 2014 21:44:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XzY0g-0005ZA-1d for pgsql-performance@arkaria.postgresql.org; Fri, 12 Dec 2014 21:44:26 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XzY0e-0005Wo-ME; Fri, 12 Dec 2014 21:44:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XzY0b-0007vF-L0; Fri, 12 Dec 2014 21:44:22 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id sBCLiAto008868; Fri, 12 Dec 2014 16:44:10 -0500 From: Tom Lane To: Josh Berkus cc: Tim Dudgeon , pgsql-sql@postgresql.org, pgsql-performance@postgresql.org Subject: Re: Re: [SQL] querying with index on jsonb slower than standard column. Why? In-reply-to: <548B5CF4.4030009@agliodbs.com> References: <5484DBDA.6090405@gmail.com> <5484EEA7.1030403@aklaver.com> <5484F437.2080402@gmail.com> <16147.1418002090@sss.pgh.pa.us> <5485C449.4020204@aklaver.com> <26002.1418053572@sss.pgh.pa.us> <5485C8BA.7040704@aklaver.com> <5485D584.8080105@aklaver.com> <27877.1418057764@sss.pgh.pa.us> <3936.1418071989@sss.pgh.pa.us> <548614C8.90203@aklaver.com> <54861A81.8030509@gmail.com> <548B5CF4.4030009@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Fri, 12 Dec 2014 13:24:04 -0800" Date: Fri, 12 Dec 2014 16:44:10 -0500 Message-ID: <8867.1418420650@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Josh Berkus writes: > Yeah, I believe the core problem is that Postgres currently doesn't have > any way to have variadic return times from a function which don't match > variadic input types. Returning a value as an actual numeric from JSONB > would require returning a numeric from a function whose input type is > text or json. So a known issue but one which would require a lot of > replumbing to fix. 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). Doesn't seem terribly nice from a usability standpoint though. 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. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance