Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b9yaC-0006hm-K3 for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jun 2016 17:45:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1b9yaB-0004xZ-Lx for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jun 2016 17:44:59 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1b9yaB-0004xS-1U for pgsql-hackers@postgresql.org; Mon, 06 Jun 2016 17:44:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1b9ya8-0006Tp-H6 for pgsql-hackers@postgresql.org; Mon, 06 Jun 2016 17:44:57 +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 u56HipDX026677; Mon, 6 Jun 2016 13:44:51 -0400 From: Tom Lane To: Tomas Vondra cc: Robert Haas , Noah Misch , Simon Riggs , David Rowley , Julien Rouhaud , Michael Paquier , Stefan Huehner , PostgreSQL mailing lists Subject: Re: pg9.6 segfault using simple query (related to use fk for join estimates) In-reply-to: <2a8adc56-6eb1-123e-8914-0cf025797262@2ndquadrant.com> References: <57238E64.8010702@dalibo.com> <22731.1462037712@sss.pgh.pa.us> <8344835e-18af-9d40-aed7-bd2261be9162@2ndquadrant.com> <16807.1462388069@sss.pgh.pa.us> <20160529053601.GE496776@tornado.leadboat.com> <20160602012954.GA619629@tornado.leadboat.com> <28109.1465064127@sss.pgh.pa.us> <039fca3d-890a-d09a-e0df-e045187eb69e@2ndquadrant.com> <23385.1465229755@sss.pgh.pa.us> <24068.1465230882@sss.pgh.pa.us> <2a8adc56-6eb1-123e-8914-0cf025797262@2ndquadrant.com> Comments: In-reply-to Tomas Vondra message dated "Mon, 06 Jun 2016 19:23:42 +0200" Date: Mon, 06 Jun 2016 13:44:51 -0400 Message-ID: <26676.1465235091@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 Tomas Vondra writes: > When it comes to improving multiple (multi-column) foreign keys, I think > it may get way more complicated that it might seem. What if the foreign > keys overlap, for example? Or what if the keys go in opposite directions > (cycle). And so on ... I think you can group all FKs referencing the same table and discard all their matched join clauses in favor of a single 1/N estimate (and when I say "discard", that means you don't match those clauses against later FKs, which should take care of the reciprocal-FK issue). This is clearly correct if no nulls are involved. We need to make some estimate of how much to de-rate that figure for nulls, but I don't see that it's any harder than what's already required for a single multicol FK. 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