Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEaNf-0006eA-Is for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Jun 2016 10:55:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bEaNf-0008PD-2n for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Jun 2016 10:55:07 +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 1bEaNd-0008O8-Qu for pgsql-hackers@postgresql.org; Sun, 19 Jun 2016 10:55:05 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bEaNV-00040j-G4 for pgsql-hackers@postgresql.org; Sun, 19 Jun 2016 10:55:05 +0000 Received: by mail-wm0-x22d.google.com with SMTP id r201so25267402wme.1 for ; Sun, 19 Jun 2016 03:54:57 -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=3dtjU0/m5zR/QQlEpF4hPImFKd1zhvAphgVpcTBgsWI=; b=K/qnkrK83RD8WanYaONHAsE2W9vYEfMPjbY9xojoLZ8+6u6Zd11Cj5i5WbbEAJF49f WTbXYXzWPskZUthmVPzJUds0l+drus3hOoYQKqFCENXkVdACQzn0kWrolM6dOsE/WDPv E3wOM0P+AkRX3GkxDcAWpMxxeTwCPPkNRAjgplKfVBkgKJDX5zsEdEd8UoNqZpOG2azJ ObJAk6RfOhDzMPYEc5wTK+2mIz+ZolY0u/ZQZ1bP8ghE3Q3uvWK3wbSDAG5FZRhl12EV Uws//v7qOwFVSzHDKorXOl7zoGZBLGNJybfcK4ivE1cj1qIh6P7m5wGctrUNgHa3OKpN CBBw== 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=3dtjU0/m5zR/QQlEpF4hPImFKd1zhvAphgVpcTBgsWI=; b=mD385V+SF5GCEMPoAbhNfPqWq3HY8q2IbblDuwLzSrVAouHWx0lj/j3pwyABbXB/62 IIACxsZodGmzs0f0q6aKootr+J21mWcYIS8LyLtJ8aildyrVWeVejt/Cc127qv/0G6+H 96wKEa1QQmKjldlMmZiTOBeAVTqqOVoGmbr87bGXIIUMBy5JhlB7Co7evxjjByAdOhkR XtcHIlRhsc54Aoy5zBLGvckOw+zxvyiLkXObJPFGdHa38c5jNFLefUu7RSUZQCiveTuq zTA0KvfpDv0EhY57LsnXjNZWBIpw2TtgbroR6IV14sFefHJL/plFG2dNw0V8CnVXQyz/ x2qg== X-Gm-Message-State: ALyK8tK7ESVyWcwr92tzZ8tFmiheapn04288YSObv8IlcEOkKRZHfdrOwv9lvbLd3uL9h++op3Gk24MV+lowU+8B4Md2AgG8ACPmSm75qx+wy7whegk2RZ1UwyCDHsL6L3nVHIo4pLxhZ5AegB2E395HoSEKwvznq2SB1UwbLAq9j9JTYna6UlGLbzI7SXUv6f7TmYdhn0jl X-Received: by 10.194.234.71 with SMTP id uc7mr11096600wjc.80.1466333696456; Sun, 19 Jun 2016 03:54:56 -0700 (PDT) Received: from [10.137.2.20] (cst-prg-61-11.cust.vodafone.cz. [46.135.61.11]) by smtp.gmail.com with ESMTPSA id q63sm3050367wma.0.2016.06.19.03.54.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Jun 2016 03:54:55 -0700 (PDT) Subject: Re: New design for FK-based join selectivity estimation To: Tom Lane References: <31041.1465069446@sss.pgh.pa.us> <25469.1465138626@sss.pgh.pa.us> <15245.1466031608@sss.pgh.pa.us> <20877.1466175216@sss.pgh.pa.us> <15396.1466268742@sss.pgh.pa.us> Cc: pgsql-hackers@postgresql.org From: Tomas Vondra Message-ID: <747f8de5-266e-cf7e-b0ab-57b8a6725517@2ndquadrant.com> Date: Sun, 19 Jun 2016 12:54:40 +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: <15396.1466268742@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.8 (-) 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 06/18/2016 06:52 PM, Tom Lane wrote: > Tomas Vondra writes: >> A few more comments, about re-reading the patch more thoroughly. I >> wouldn't say any of those qualify as bugs, but rather as discussion >> about some of the design choices: > >> 1) NULL handling > >> I'd argue that we should do something about this, although I agree it's >> non-trivial to estimate - at least until we get some sort of correlation >> stats (e.g. my patch already provides most of the pieces, I believe). > > I concur, actually, but I feel that it's out of scope for this > particular patch, which is only trying to replace the functionality > that was committed previously. If you want to come up with a patch on > top of this that adds some accounting for NULLs, I'd be willing to > consider it as a post-beta2 improvement. Sure, fair enough. By post-beta2 you mean for 9.7, or still for 9.6? > >> But I'd argue that in the case of multi-column foreign keys we can do >> better even without it - my experience is that in such cases either all >> values are NULL or none of them, and a single NULL value breaks the FK >> of course. So I think max(null_frac) would work. > > Yeah, I was thinking along the same lines: max of the per-column null > fractions is probably an OK estimate. OK > >> 3) ForeignKeyOptInfo->rinfos as a List >> Can we actually get a list of matching RestrictInfos for a single >> foreign key? I've been unable to construct such query. > > I think you'd actually have to write redundant outer join quals, > along the lines of > select ... a left join b on (a.x = b.y and a.x = b.y) > I don't believe we take the trouble to eliminate such duplicates > unless they get absorbed by an EC, which outer-join quals would > not be. (Haven't tried this, though, as I don't have the patch > installed right now.) OK. Let's look into this post-beta2 then. > > The beta2 deadline is just about upon us; I feel that if we're going > to get this into this release at all, we need to push it today so > that we get a full buildfarm cycle on it before the wrap. > > I plan to spend an hour or two adjusting the qual match logic as > discussed above, and re-reading the whole patch another time for > sanity. If I've not heard objections by the time I'm done, > I will push it. > Thanks! If I could wish one more thing - could you briefly explain why you rewrote the patch the way you did? I'd like to learn from this and while I think I kinda understand most of the changes, I'm not really sure I got it right. 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