Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aySHw-0008S9-6t for pgsql-hackers@arkaria.postgresql.org; Thu, 05 May 2016 23:02:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aySHv-0000Qy-PS for pgsql-hackers@arkaria.postgresql.org; Thu, 05 May 2016 23:02:31 +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 1aySGa-0006dG-ND for pgsql-hackers@postgresql.org; Thu, 05 May 2016 23:01:08 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1aySGW-0001Jv-Kt for pgsql-hackers@postgresql.org; Thu, 05 May 2016 23:01:08 +0000 Received: by mail-wm0-x234.google.com with SMTP id e201so37791960wme.0 for ; Thu, 05 May 2016 16:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=9dr/5Xo0R2O4Nfy5G89T+UYD1RcNe+GKD4Q3AZf3LdI=; b=fjwTU5uwsvwl3cijLco8UtJ5QUg5zWK8DwJtm10P1Z1k8HeDQ46GllHinTpRV+Na74 iBNvwjeB1OL7XduSwAGCwwGSOqn9M+rrTtvN5n4VduN4GyXSvDrIzk2wG+5HoaseG325 iivSYdwH7u4G5AKvPjE5WGLDQl5WLsLJQBsvu7rjwalsr1TeDbTr1F+0YnOt8yVESbz2 CW1C+h7VaiMfg2hXeMGYQb2X9jNgg57QDCcKfg/XbzZY2ldmXbVh+Px7gXwhoTEVfE/g OcoZi/Qnk5fZ18MSalfHxfoQ9471apAfMhk+vFYJkbDJZUgFVya4wB2lCSkeiAz2hSIU 9eSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=9dr/5Xo0R2O4Nfy5G89T+UYD1RcNe+GKD4Q3AZf3LdI=; b=hVSSp89F6Y+7ELRgAHtQj5k1YKisTPHSouxX7avsjtzNjdJguanHCGOxbwfl/f5zrv angZt43kuhKcEcVKPPPHdvJ9GoiWekSKZ8a9FMhbOz7k7f6fyUS3CR5PW21JNZT/5Hpg 7bSxt3EOF3E20mMZYPobe8iMk+BScQf2NWI2eeEJVtJRAYpo2t21m+xekCE5mQRsb6Rl MIEwZUqkWmeLePOCCxuzorud6nMci4iW5IawOx7M76AKiexwJDfA2zq2avPNkYiUI798 ZVKaGbXjD5lzrdgBTdHRSlikzAgEiZwCiNKpB9PadTdBoxpk8RBp+UrLmOrTFx1TtGax ENDA== X-Gm-Message-State: AOPr4FVXFuJKPQ5HUcS+PCv8wYPfrI7dTG09uuaBa0Va4uhIpXXCZ9WUFbH9CZZFMetekF2KAs3dgCnkln4NJ1OjaQFbPj4ZaPlUEKj8uq0/uK+5L7bjSyqCII/g/9mH0wvvb35r9B6oOuHIM56dvUiJnt6Z8K+OioovB/OrZ0vDvvmyFrwDclCpKFkwsQqA9PzpgDrgw484 X-Received: by 10.194.247.70 with SMTP id yc6mr16273462wjc.45.1462489263239; Thu, 05 May 2016 16:01:03 -0700 (PDT) Received: from [10.137.2.17] (ip-89-177-44-58.net.upcbroadband.cz. [89.177.44.58]) by smtp.gmail.com with ESMTPSA id a75sm5390926wme.18.2016.05.05.16.01.01 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 May 2016 16:01:02 -0700 (PDT) Subject: Re: pg9.6 segfault using simple query (related to use fk for join estimates) To: David Rowley , Tom Lane References: <20160429102531.GA13701@huehner.biz> <572384D7.1020602@dalibo.com> <17639.1461945908@sss.pgh.pa.us> <57238E64.8010702@dalibo.com> <22731.1462037712@sss.pgh.pa.us> <8344835e-18af-9d40-aed7-bd2261be9162@2ndquadrant.com> <16807.1462388069@sss.pgh.pa.us> Cc: Julien Rouhaud , Simon Riggs , Michael Paquier , Stefan Huehner , PostgreSQL mailing lists From: Tomas Vondra Message-ID: <4cf45f48-5e92-903b-9f29-af5215fdf715@2ndquadrant.com> Date: Fri, 6 May 2016 01:00:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:46.0) Gecko/20100101 Thunderbird/46.0a2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) 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 Hi, On 05/05/2016 04:48 PM, David Rowley wrote: > On 5 May 2016 at 16:04, David Rowley wrote: >> I've started making some improvements to this, but need to talk to >> Tomas. It's currently in the middle of his night, but will try to >> catch him in his morning to discuss this with him. > > Ok, so I spoke to Tomas about this briefly, and he's asked me to > send in this patch. He didn't get time to look over it due to some > other commitments he has today. > Thanks! > > I do personally feel that if the attached is not good enough, or not > very close to good enough then probably the best course of action is > to revert the whole thing. I'd much rather have this out than to > feel some responsibility for someone's performance problems with > this feature. > I share this opinion. If the approach proposed here is deemed not good enough, then +1 to revert. I think we can further limit the impact by ignoring foreign keys on a single column, because the primary goal of the patch is improving estimates with multi-column FKs (and matching joins). I'd argue that 99% of the FKs in practice is single-column ones, but sure - if you have a database with many multi-column FKs this won't help. I think it's also important to point out that whatever solution we choose, it should probably allow us to relax some of the restrictions in the future. For example, with a FK on 3 columns, the current patch only handles a "full match" joins, with conditions on all three columns. But it may be possible to also improve estimates on just two columns - the current patch does not do that, as that needs definitely further more thought and discussion. > > But I also do feel that the patch allows a solution to a big problem > that we currently have with PostgreSQL, which there's any easy > workarounds for... that's multi-column join estimates. > In a sense, yes. FKs allow us to improve estimates for a fairly narrow case of multi-column estimates - joins matching multi-column FKs. And for this (not entirely narrow) case they are actually more accurate and way cheaper than e.g. histograms or MCV lists (at least in the multi-column case). FWIW the current multivariate stats patch does not even try to mess with joins, as it's quite complicated in the multi-column case. > > In the attached I've left the GUC remaining. The reason for the GUC > is for testing purposes and it should be removed before release. It > should likely be documented though, even if we're planning to remove > it later. I've not gotten around to that in this patch though. > Yes, removal of the GUC should go to the Open Items list. I'd also like to make it clear that all the shitty parts of the patch are my fault, not David's. His name is on the patch as he provided a lot of useful ideas, pieces of code and feedback in general. But it was up to me to craft the final patch - and I clearly failed to do so. I think David still feels responsible for the patch as he made a lot of effort to salvage it over the last few days, so I'd like to set the record straight. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers