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.89) (envelope-from ) id 1iVJmg-0004Ry-MI for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Nov 2019 18:23:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iVJmd-0003qr-DH for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Nov 2019 18:23:55 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1iVJmd-0003qk-1J for pgsql-hackers@lists.postgresql.org; Thu, 14 Nov 2019 18:23:55 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iVJmV-0005kL-VN for pgsql-hackers@postgresql.org; Thu, 14 Nov 2019 18:23:54 +0000 Received: by mail-pf1-x429.google.com with SMTP id s5so4805552pfh.9 for ; Thu, 14 Nov 2019 10:23:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ZcWAEqdVV7mvhKO9tFaRkCB5SacLrjgY03c7DhsUlp0=; b=dHIQKXaD9+lWgX5L7jFWpwJusDd3EhgWnQWMOklbnm50crI5G+eQUFiZqAC4X7u8g1 LMjEEdeVZj5DRaDHCWcqpQN/TOuO9h/t/qoNVtTzaF6nswCZZhPejzJSkXh2FLXQaSSX MLlKHuQnpEl9sFV04DPDyZ3REUTHX6IFzB6+YBzvdtW2aqiYG4Xr1hQa4gMtqmoa7BOA aoHlPDfgxBdyCeGIEuvT9Tmm1ul/cA2JFjy/KLwVNmeyM09ioWg1rv8lnV48EDwj0ZHN ri1IwF+SG/f/VXGxmq1X4veJ0/lT0+HhVSqor95Tg+GXh9Qs6yUn0uIC+A+NAxvTGObc ghzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ZcWAEqdVV7mvhKO9tFaRkCB5SacLrjgY03c7DhsUlp0=; b=UJuAp6NwLRnfad71RAIjjcKLG5k0tDhTJp0iSM7WWLHpj/MXb1dj19a9b9wEcJw6te XaDuGueHcT/z7+qgp+SY4LofXAR3nm/HNT3GsE50fk4ZxB+WHBwq+OxV3q2//mx5Z04u 1XLpFi32nQXjVrWWBfk56mIbSgmDCdoth0PbZgRftkdNy6Xwf+njttC5nP043rfhDCOo YzzqKU81H5i35JvZaHQUryVxS/AVgSdmLT4EXXCta7iMWI+Abu5j6Yz30bReMwMlLsq3 pwg9Ysmn6Z8ulAe7ZhxwAiELhLPlUSCaf9oo9oJMeA0juCXICLuo3/O2DmalG9s56Hu6 icMw== X-Gm-Message-State: APjAAAULRJ0qkLHvYc14pn2oO2Plt4D4DQ/XuFqmCRhBhenGyFYFl2hm 42NGpQivggRJ3YC/05cpX5G1BfGY X-Google-Smtp-Source: APXvYqz4bxvIztuv46mDRR9DLVCz8aIFp5qUD7kG2/qrvW2ELNnzei9xo4WhyDiPTbdMs43LIgCaBg== X-Received: by 2002:a63:5c4a:: with SMTP id n10mr12013497pgm.120.1573755825086; Thu, 14 Nov 2019 10:23:45 -0800 (PST) Received: from [192.168.0.17] (24-113-193-150.wavecable.com. [24.113.193.150]) by smtp.gmail.com with ESMTPSA id b24sm6435982pgk.93.2019.11.14.10.23.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Nov 2019 10:23:44 -0800 (PST) Subject: Re: Using multiple extended statistics for estimates To: Tomas Vondra Cc: PostgreSQL Hackers References: <20191028152048.jc6pqv5hb7j77ocp@development> <20191106195440.wtxsyhiwdidl37hv@development> <20191106195849.odhhc66xd23hw6hf@development> <97932e1d-53f1-bad3-efc2-1d98cab70727@gmail.com> <0da76f1f-5f9c-3ce3-3ac6-042d2a18430a@gmail.com> <20191110173428.w5klequcmb6gawaa@development> <20191113152823.jdpertc73gfo2mk7@development> <2e183f8d-1304-6024-90de-1017a861a235@gmail.com> <20191114155541.zliellgi2if4bb5f@development> From: Mark Dilger Message-ID: Date: Thu, 14 Nov 2019 10:23:44 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: <20191114155541.zliellgi2if4bb5f@development> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/14/19 7:55 AM, Tomas Vondra wrote: > On Wed, Nov 13, 2019 at 10:04:36AM -0800, Mark Dilger wrote: >> >> >> On 11/13/19 7:28 AM, Tomas Vondra wrote: >>> Hi, >>> >>> here's an updated patch, with some minor tweaks based on the review and >>> added tests (I ended up reworking those a bit, to make them more like >>> the existing ones). >> >> Thanks, Tomas, for the new patch set! >> >> Attached are my review comments so far, in the form of a patch applied >> on top of yours. >> > > Thanks. > > 1) It's not clear to me why adding 'const' to the List parameters would >   be useful? Can you explain? When I first started reviewing the functions, I didn't know if those lists were intended to be modified by the function. Adding 'const' helps document that the function does not intend to change them. > 2) I think you're right we can change find_strongest_dependency to do > >    /* also skip weaker dependencies when attribute count matches */ >    if (strongest->nattributes == dependency->nattributes && >        strongest->degree >= dependency->degree) >        continue; > >   That'll skip some additional dependencies, which seems OK. > > 3) It's not clear to me what you mean by > >     * TODO: Improve this code comment.  Specifically, why would we >     * ignore that no rows will match?  It seems that such a discovery >     * would allow us to return an estimate of 0 rows, and that would >     * be useful. > >   added to dependencies_clauselist_selectivity. Are you saying we >   should also compute selectivity estimates for individual clauses and >   use Min() as a limit? Maybe, but that seems unrelated to the patch. I mean that the comment right above that TODO is hard to understand. You seem to be saying that it is good and proper to only take the selectivity estimate from the final clause in the list, but then go on to say that other clauses might prove that no rows will match. So that implies that by ignoring all but the last clause, we're ignoring such other clauses that prove no rows can match. But why would we be ignoring those? I am not arguing that your code is wrong. I'm just critiquing the hard-to-understand phrasing of that code comment. -- Mark Dilger