Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bILH8-0003uk-TW for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Jun 2016 19:35:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bILH8-0007jI-GW for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Jun 2016 19:35:54 +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 1bILFm-0005qU-DQ for pgsql-hackers@postgresql.org; Wed, 29 Jun 2016 19:34:30 +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 1bILFj-0005xS-SX for pgsql-hackers@postgresql.org; Wed, 29 Jun 2016 19:34:29 +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 u5TJYPOZ025870; Wed, 29 Jun 2016 15:34:25 -0400 From: Tom Lane To: Andrew Gierth cc: Tomas Vondra , pgsql-hackers@postgresql.org Subject: Re: New design for FK-based join selectivity estimation In-reply-to: <87poqzg6f7.fsf@news-spur.riddles.org.uk> References: <31041.1465069446@sss.pgh.pa.us> <25469.1465138626@sss.pgh.pa.us> <15245.1466031608@sss.pgh.pa.us> <87poqzg6f7.fsf@news-spur.riddles.org.uk> Comments: In-reply-to Andrew Gierth message dated "Wed, 29 Jun 2016 20:18:16 +0100" Date: Wed, 29 Jun 2016 15:34:25 -0400 Message-ID: <25869.1467228865@sss.pgh.pa.us> X-Pg-Spam-Score: -3.2 (---) 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 Andrew Gierth writes: > If the query was produced by rule expansion then the code that populates > fkinfo includes FK references to the OLD and NEW RTEs, but those might not > appear in the jointree (the testcase for the bug is a DELETE rule where > NEW clearly doesn't apply) and hence build_simple_rel was not called > (causing find_base_rel to fail). Not sure what the right fix is. Meh. I had a vaguely uneasy feeling that just scanning the rtable was too simplistic, but hadn't thought hard about it. For a really correct fix we could search the jointree to see which rels are in it, but that would add code and cycles. A slightly cheating way to do it is to not use find_base_rel() but look into the simple_rel_array for ourselves, and do nothing if there's no rel corresponding to the RTE index. 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