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 1ibBkE-0005IF-IA for pgsql-hackers@arkaria.postgresql.org; Sat, 30 Nov 2019 23:01:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ibBkC-0006W0-La for pgsql-hackers@arkaria.postgresql.org; Sat, 30 Nov 2019 23:01:40 +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 1ibBkC-0006UO-6Q for pgsql-hackers@lists.postgresql.org; Sat, 30 Nov 2019 23:01:40 +0000 Received: from mail-yw1-xc35.google.com ([2607:f8b0:4864:20::c35]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ibBk7-00018M-Nr for pgsql-hackers@postgresql.org; Sat, 30 Nov 2019 23:01:38 +0000 Received: by mail-yw1-xc35.google.com with SMTP id r131so12391739ywh.2 for ; Sat, 30 Nov 2019 15:01:35 -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=fK5GT4PgKnxKDD0W2/hVxNFSc7P5kZb8BTP+FKF8ZBM=; b=Ih979iJ1iQlozWZ6nIU4lMBQ1TU+TriiYb4rWsYn8CTRK/b+tuIALuS81WlBi6qJ+C CN5H2XZU7xyo6uZI9GdlqqbjxJSVqYUUSS4ZNpzREscv0mHnUEMeSvx/SZ3WxZx3Xy2d bIyExTB9IoISkDyGmUFMlAtg817CHohpzlIGrHiPrpmCPq0G7luOaSjPwcIN9+vcPKYj dVCGke8C8/uB5cYoUzuN46jc+Ucll2iLpGH59gUlVGG5OYTxiuBeh+4MJaRav9/Y+0Zp fEXYWrCVe/ayGyxY7ej6GWWtPWpOVRD1Bx6ZGW99ngc9tuzNrWYJsTHG8crJUPd5CdTR TM4Q== 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=fK5GT4PgKnxKDD0W2/hVxNFSc7P5kZb8BTP+FKF8ZBM=; b=ovgDomZrILvLOO+DMhe6JMk4dbKIYzUmcMuEa9AucXQPoM60FnPR4JUgY9B48TfGOZ dX2NdLcwUTH8WeIPQwnS9G7354NefoVqcu0HJId+JqAfGo5z1H1RykHOGcOGX8R0/oRn Pj8xhNfbZGpyaPEKB7og6Sud3pg1pxbldy22jTfbTZtFoZ9HW8qXViJPqZjQY8ymx81b ASN4S+RM5iz3SOUOTGKD/9Sm9fIae24hE+ph2/l/Mp5yn3fo6AKSQGgqfcexQRg9Zvg1 AxI1k2KHr4CSP0i1KWoOV2hwJ+BHbDQNs1xRk+Oi1uoWagRE1vg5IgwZ0VvK8MVl0CY0 fo6A== X-Gm-Message-State: APjAAAXvGybkLbCfr6wch+EJAKbWF9FDUI18pm1asuNj2W4neCUd0v4P vPVn3LHSuMeth+ROXUX5IaRDarMw X-Google-Smtp-Source: APXvYqw0lIOHKKHBga/BU8GubS+A6QbA0j4mZNO69edWAZen5DOAzumIVv3rKXzru75Q9i/LtJ7fpA== X-Received: by 2002:a0d:efc6:: with SMTP id y189mr16690591ywe.87.1575154894040; Sat, 30 Nov 2019 15:01:34 -0800 (PST) Received: from [192.168.1.8] (static-50-53-66-203.bvtn.or.frontiernet.net. [50.53.66.203]) by smtp.gmail.com with ESMTPSA id t5sm4083395ywt.4.2019.11.30.15.01.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 Nov 2019 15:01:33 -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> <20191114200420.c3x2jf7ywzs23uzo@development> From: Mark Dilger Message-ID: Date: Sat, 30 Nov 2019 15:01:31 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20191114200420.c3x2jf7ywzs23uzo@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 12:04 PM, Tomas Vondra wrote: > On Thu, Nov 14, 2019 at 10:23:44AM -0800, Mark Dilger wrote: >> >> >> 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. >> > > Hmmm, ok. I'll think about it, but we're not really using const* in this > way very much I think - at least not in the surrounding code. > >>> 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. >> > > Aha, I think I understand now - thanks for the explanation. You're right > the comment is trying to explain why just taking the last clause for a > given attnum is fine. I'll try to make the comment clearer. Are you planning to submit a revised patch for this? -- Mark Dilger