Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bCWPZ-0007m0-Ah for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Jun 2016 18:16:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bCWPY-0007L9-ST for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Jun 2016 18:16:32 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bCWPX-0007KR-Ml for pgsql-hackers@postgresql.org; Mon, 13 Jun 2016 18:16:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bCWPU-0004RI-8s for pgsql-hackers@postgresql.org; Mon, 13 Jun 2016 18:16:31 +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 u5DIGPS1029765; Mon, 13 Jun 2016 14:16:25 -0400 From: Tom Lane To: Simon Riggs cc: PostgreSQL-development Subject: Re: New design for FK-based join selectivity estimation In-reply-to: References: <31041.1465069446@sss.pgh.pa.us> Comments: In-reply-to Simon Riggs message dated "Mon, 13 Jun 2016 18:28:36 +0100" Date: Mon, 13 Jun 2016 14:16:25 -0400 Message-ID: <29764.1465841785@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Simon Riggs writes: > So a simple change is to make RelationGetFKeyList() only retrieve FKs with > nKeys>1. Rename to RelationGetMultiColumnFKeyList(). That greatly reduces > the scope for increased planning time. FWIW, I don't particularly agree with that. It makes the relcache's fkey storage extremely specific to this one use-case, a decision I expect we'd regret later. And the planner needs to filter the fkey list anyway, because it only wants fkeys that link to tables that are also in the current query. Thus, my recommendation was that we should allow RelationGetFKeyList to return a pointer directly to the cached info list and require the planner to immediately copy (only) the entries that it needs for the current query. Another point here is that I'm now unconvinced that restricting the logic to consider only multi-column fkeys is really what we want. It looks to me like the code can also improve estimates in the case where there are multiple single-column FKs linking to the same target relation. That might not be too common for two-table queries, but I bet it happens a lot in three-or-more-table queries. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers