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 1gnmC4-0003qq-7z for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Jan 2019 15:17: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 1gnmC1-0006Uc-Qf for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Jan 2019 15:17:53 +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 1gnmC1-0006UU-J6 for pgsql-hackers@lists.postgresql.org; Sun, 27 Jan 2019 15:17:53 +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 1gnmBu-0007L1-No for pgsql-hackers@lists.postgresql.org; Sun, 27 Jan 2019 15:17:52 +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 x0RFHh7l000525; Sun, 27 Jan 2019 10:17:43 -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> Comments: In-reply-to Simon Riggs message dated "Sun, 27 Jan 2019 08:00:31 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <523.1548602263.1@sss.pgh.pa.us> Date: Sun, 27 Jan 2019 10:17:43 -0500 Message-ID: <524.1548602263@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Simon Riggs writes: > On Sun, 20 Jan 2019 at 23:48, Tom Lane wrote: >> What I'm envisioning therefore is that we allow an auxiliary function ... > Does this help with these cases? > * Allow a set returning function to specify number of output rows, in cases > where that is variable and dependent upon the input params? Yes, within the usual limits of what the planner can know. The 0004 patch I posted yesterday correctly estimates the number of rows for constant-arguments cases of generate_series() and unnest(anyarray), and it also understands unnest(array[x,y,z,...]) even when some of the array[] elements aren't constants. There's room to add knowledge about other SRFs, but those are cases I can recall hearing complaints about. > * Allow a normal term to match a functional index, e.g. WHERE x = > 'abcdefgh' => WHERE substr(x, 1 , 5) = 'abcde' AND x = 'abcdefgh' I'm a bit confused about what you think this example means. I do intend to work on letting extensions define rules for extracting index clauses from function calls, because that's the requirement that PostGIS is after in the thread that started this. I don't know whether that would satisfy your concern, because I'm not clear on what your concern is. > * Allow us to realise that ORDER BY f(x) => ORDER BY x so we can use > ordered paths from indexes, or avoid sorts. Hm. That's not part of what I'm hoping to get done for v12, but you could imagine a future extension to add a support request type that allows deriving related pathkeys. There would be a lot of work to do to make that happen, but the aspect of it that requires adding function-specific knowledge could usefully be packaged as a support-function request. regards, tom lane