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 1iVHTJ-0007gf-V3 for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Nov 2019 15:55:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iVHTI-0002e5-Q7 for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Nov 2019 15:55:48 +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 1iVHTI-0002dw-9N for pgsql-hackers@lists.postgresql.org; Thu, 14 Nov 2019 15:55:48 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iVHTF-0003FT-CH for pgsql-hackers@postgresql.org; Thu, 14 Nov 2019 15:55:47 +0000 Received: by mail-wm1-x32c.google.com with SMTP id j18so7802229wmk.1 for ; Thu, 14 Nov 2019 07:55:45 -0800 (PST) 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=UV8VINJmpExoPVtMyR7f7SRuLszvyOECYN5RVNRC15U=; b=1wNV+OrylZBnEcdbN3VTVCP042nkwv4/qkeRJbrTZkkqqVB4FYUaT0R9W0d2+U8c4R sgNRuSmpPSNjGMOZHotLikojRRO1Wc1s4dJSFJupadn0t6IwpJ2AzGgj2LKe6Jy/I5bz T+RzCryQbLygm2c8raSJKgrxfxu1oEXM2Dj7YGxHslXe+PKPxbUVXB96y/j/a+h+d6TS jWilgH6LNYCOnqSHOGW1ImKGVmiLZS+N5fs3xDAXC/UKbr2NaJq/5LLzRt3MkKTOlO70 KVeRSY7Q6nBQURShiDrNEyu/Br3YbCpHiUfvNE6HPFY7HhPafoH4vTbui9ArDihb76I2 NvQQ== 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=UV8VINJmpExoPVtMyR7f7SRuLszvyOECYN5RVNRC15U=; b=gPbuN74kvNlSllBTJeYfrBYWjUSmOxruth/SadixtA6IT+tiIWL9fpwC1o9l6JbIxT rT6GDMdBssdKeGlWzH3Twbs1FdW8vRhqmuxPNdaKz4f6EsQD0dF9eM5OzLOZr2HrBlh/ GmRp/xg2OQ6Ri95rA3FiXdQBoyuIHG4Y7XvN1ruNwu42KvBYbRn9WO2PXpj2gPZCtOUd KiYcq76+CIrD86MWEIK5mbr37RhjmP4pvskjYbgrkZ83tdvHc8B6N0+J8chR74MQFf4k 9xl+Gdmzur7qPqr1pDabmk2HajYl3gpNL02Jb5KRUACXGlX9dOqvfBoDc6gphx06fF/i 3f5g== X-Gm-Message-State: APjAAAUGSPGKXAeqzAnfOb6oiu2GqpAABL7blu6D3eri0UC6RFMApnU5 0+3TUvoOv6kRYMAEo9KLmK1Zag== X-Google-Smtp-Source: APXvYqwlbmRKJwYyOeJyPjiHjF6tBSuCLl0bJJxEEgsO5sSG5QEQG65QWvoIPXozinwYxZ0vxbuJqQ== X-Received: by 2002:a1c:de88:: with SMTP id v130mr9019945wmg.89.1573746943845; Thu, 14 Nov 2019 07:55:43 -0800 (PST) Received: from localhost (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id 19sm9420206wrc.47.2019.11.14.07.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 07:55:43 -0800 (PST) Date: Thu, 14 Nov 2019 16:55:41 +0100 From: Tomas Vondra To: Mark Dilger Cc: PostgreSQL Hackers Subject: Re: Using multiple extended statistics for estimates Message-ID: <20191114155541.zliellgi2if4bb5f@development> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <2e183f8d-1304-6024-90de-1017a861a235@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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? 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. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services