Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jEMap-0005tH-Mg for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2020 00:29:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jEMao-0000fP-AD for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2020 00:29:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jEMan-0000fG-Qp for pgsql-hackers@lists.postgresql.org; Wed, 18 Mar 2020 00:29:54 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jEMak-0008J7-Qg for pgsql-hackers@lists.postgresql.org; Wed, 18 Mar 2020 00:29:52 +0000 Received: by mail-wr1-x436.google.com with SMTP id v11so28169868wrm.9 for ; Tue, 17 Mar 2020 17:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=IayrdADKziCRgJMJckFKqn0dnU3pkCp4Kv7xgNuRblg=; b=YOkU9/a9byACSNbXb96LD1i7uavtmrXmesPHBG9+D9mt2nlK/I++BPmDz9ods3xdGF C8DSUpSACyyaICICOGRRw2teH7kWKqdmX5MWb4ZqM2VsFcmsn8TZSlNTf6V9dGydGDJX 7EX/KLrqJWrSHl74IEqzbLCYeTaDPiYLxybsZaiO2sKE/ECx5C0hJyvL9EtXU5atiT1d t2LhoExUBDG/lPwlrI/a6Y1Wuw6W8tnBJFtEyhJW0pe3niA8lio756ro9b3ELpPrSatZ rXupRedFVXXwI4Z9QLBokSbVT6GEcG0vhLa0R65MxnTHBfagtREsZzgguL2V3fO9qUBS JXNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=IayrdADKziCRgJMJckFKqn0dnU3pkCp4Kv7xgNuRblg=; b=lrgMUGxr6hhCGU02FCw241c5IOBEDq5FoZyC4tv33SwmNhIb1OeAhYYcmbwVf24QNr JJNppDLyNwtWS57/pQ0sn/wv4BuGUYXLa4K+KQsabnYWoRfWKUIODKXXjA4aSoyS4hlV FYouGA/u0itQ2GXgWC87MTVosDvxeBhEX3frvXguFxP7ZlSfAcKSxaJ3wLxCmX25lXLI 1bHMfdw0hnJHhrUhzkjWSNWi+V66o3XYDwrBFVcwOt9G5NyeABSFYatASLHvq2ryPP9h sQIB6wt8vnlkEvur5gp7oHrIhsU6KjAay5iSqyQtQp1tb5HxbBXILlVLIxPyJCb1jRLY 6ogQ== X-Gm-Message-State: ANhLgQ31UaZo/y6NBP0oVwZ6YDZYIR900a/a7KYonBmcLzbEcka7+3zl DIGtTL7kiOsrM8HV/7oieFy9/g== X-Google-Smtp-Source: ADFU+vvNAGiSaKpdqT4wh5z8J2nxcnUBbubxfpEIYO+fgGsU6mZtazBNurn4Cl79eA55USSxD/RH0A== X-Received: by 2002:a5d:680f:: with SMTP id w15mr1651967wru.245.1584491389197; Tue, 17 Mar 2020 17:29:49 -0700 (PDT) Received: from localhost (ip-86-49-253-92.net.upcbroadband.cz. [86.49.253.92]) by smtp.gmail.com with ESMTPSA id w1sm1311524wmc.11.2020.03.17.17.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 17:29:48 -0700 (PDT) Date: Wed, 18 Mar 2020 01:29:46 +0100 From: Tomas Vondra To: Dean Rasheed Cc: Pierre Ducroquet , PostgreSQL Hackers Subject: Re: PATCH: add support for IN and @> in functional-dependency statistics use Message-ID: <20200318002946.6dvblukm3cfmgir2@development> References: <20200312173047.stp55sxoj4sipn7q@development> <20200313160944.aqrbkyf7tkasoxfk@development> <20200314152159.5webesf6pfluatqj@development> <20200314184535.4jgkxcyg5yprvsra@development> <20200317153706.z6pdtijr25iyr424@development> <20200317170517.hutarq3sioyny3wa@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200317170517.hutarq3sioyny3wa@development> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Mar 17, 2020 at 06:05:17PM +0100, Tomas Vondra wrote: >On Tue, Mar 17, 2020 at 04:14:26PM +0000, Dean Rasheed wrote: >>On Tue, 17 Mar 2020 at 15:37, Tomas Vondra wrote: >>> >>>On Tue, Mar 17, 2020 at 12:42:52PM +0000, Dean Rasheed wrote: >>> >>>>The other thing that I'm still concerned about is the possibility of >>>>returning estimates with P(a,b) > P(a) or P(b). I think that such a >>>>thing becomes much more likely with the new types of clause supported >>>>here, because they now allow multiple values from each column, where >>>>before we only allowed one. I took another look at the patch I posted >>>>on the other thread, and I've convinced myself that it's correct. >>>>Attached is an updated version, with some cosmetic tidying up and now >>>>with some additional regression tests. >>> >>>Yeah, I agree that's something we need to fix. Do you plan to push the >>>fix, or do you want me to do it? >>> >> >>I can push it. Have you had a chance to review it? >> > >Not yet, I'll take a look today. > OK, I took a look. I think from the correctness POV the patch is OK, but I think the dependencies_clauselist_selectivity() function now got a bit too complex. I've been able to parse it now, but I'm sure I'll have trouble in the future :-( Can we refactor / split it somehow and move bits of the logic to smaller functions, or something like that? Another thing I'd like to suggest is keeping the "old" formula, and instead of just replacing it with P(a,b) = f * Min(P(a), P(b)) + (1-f) * P(a) * P(b) but explaining how the old formula may produce nonsensical selectivity, and how the new formula addresses that issue. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services