Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YF2De-0001gB-Ic for pgsql-bugs@arkaria.postgresql.org; Sat, 24 Jan 2015 15:01:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YF2Dd-0002eL-BJ for pgsql-bugs@arkaria.postgresql.org; Sat, 24 Jan 2015 15:01:49 +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 1YF2Db-0002eB-Al for pgsql-bugs@postgresql.org; Sat, 24 Jan 2015 15:01:47 +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 1YF2DP-0008S2-MZ for pgsql-bugs@postgresql.org; Sat, 24 Jan 2015 15:01:45 +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 t0OF1VXp016693; Sat, 24 Jan 2015 10:01:32 -0500 From: Tom Lane To: Jim@mcdee.net cc: pgsql-bugs@postgresql.org Subject: Re: BUG #12644: Planner fails to use available index with anything other than default operator In-reply-to: <20150123181759.32669.55573@wrigleys.postgresql.org> References: <20150123181759.32669.55573@wrigleys.postgresql.org> Comments: In-reply-to Jim@mcdee.net message dated "Fri, 23 Jan 2015 18:17:59 +0000" Date: Sat, 24 Jan 2015 10:01:31 -0500 Message-ID: <16692.1422111691@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-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Jim@mcdee.net writes: > Using psql I can run a simple select and it uses the index as expected: > EXPLAIN ANALYZE SELECT d FROM jsonthings WHERE d->'name' ? 'First'; > However I cannot use the '?' operator because I'm accessing the database > through JDBC and there is no way to escape the '?' character. Seems to me you need to discuss that problem with the pgsql-jdbc folk. (I suspect they have some solution already, because operators whose names contain '?' have been around for a very very long time.) > Instead I attempted to use the functino which underpins the '?' > operator, however it is not using the index: Nope, this doesn't work, never has, and will not in the foreseeable future. Index access is defined in terms of operators, not other ways to access the same function; see http://www.postgresql.org/docs/9.4/static/indexes-opclass.html Possibly the Berkeley crew should have done it the other way; but they didn't, and we're unlikely to try to move that mountain now. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs