Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goMNI-0007Fu-Oq for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Jan 2019 05:55:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1goMNH-0007Pw-4q for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Jan 2019 05:55:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goMNG-0007Pp-Tp for pgsql-hackers@lists.postgresql.org; Tue, 29 Jan 2019 05:55:54 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goMNE-0001cN-8p for pgsql-hackers@lists.postgresql.org; Tue, 29 Jan 2019 05:55:54 +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 x0T5tlQ6030312; Tue, 29 Jan 2019 00:55:47 -0500 From: Tom Lane To: Simon Riggs cc: PostgreSQL Hackers Subject: Re: Allowing extensions to supply operator-/function-specific info In-reply-to: References: <15193.1548028093@sss.pgh.pa.us> <524.1548602263@sss.pgh.pa.us> Comments: In-reply-to Simon Riggs message dated "Tue, 29 Jan 2019 05:33:03 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30310.1548741347.1@sss.pgh.pa.us> Date: Tue, 29 Jan 2019 00:55:47 -0500 Message-ID: <30311.1548741347@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Simon Riggs writes: > On Sun, 27 Jan 2019 at 19:17, Tom Lane wrote: >> ... I don't >> know whether that would satisfy your concern, because I'm not clear >> on what your concern is. > To be able to extract indexable clauses where none existed before. That's a pretty vague statement, because it describes what I want to do perfectly, but this doesn't: > Hash functions assume that x = N => hash(x) = hash(N) AND x = N > so I want to be able to assume > x = K => f(x) = f(K) AND x = K > for specific f() > to allow indexable operations when we have an index on f(x) only The problem with that is that if the only thing that's in the query is "x = K" then there is nothing to cue the planner that it'd be worth expending cycles thinking about f(x). Sure, you could hang a planner support function on the equals operator that would go off and expend arbitrary amounts of computation looking for speculative matches ... but nobody is going to accept that as a patch, because the cost/benefit ratio is going to be awful for 99% of users. The mechanism I'm proposing is based on the thought that for specialized functions (or operators) like PostGIS' ST_Intersects(), it'll be worth expending extra cycles when one of those shows up in WHERE. I don't think that scales to plain-vanilla equality though. Conceivably, you could turn that around and look for support functions attached to the functions/operators that are in an index expression, and give them the opportunity to derive lossy indexquals based on comparing the index expression to query quals. I have no particular interest in working on that right now, because it doesn't respond to what I understand PostGIS' need to be, and there are only so many hours in the day. But maybe it could be made workable in the future. regards, tom lane