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 1i8VCf-0007ax-FD for pgsql-general@arkaria.postgresql.org; Thu, 12 Sep 2019 19:56:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i8VCe-0006E5-Bw for pgsql-general@arkaria.postgresql.org; Thu, 12 Sep 2019 19:56:28 +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 1i8VCe-0006Ds-1b for pgsql-general@lists.postgresql.org; Thu, 12 Sep 2019 19:56:28 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8VCb-0000ew-IV for pgsql-general@lists.postgresql.org; Thu, 12 Sep 2019 19:56:27 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id CEA23839; Thu, 12 Sep 2019 21:56:22 +0200 (CEST) Date: Thu, 12 Sep 2019 21:56:22 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Strange Behaviour with multicolumn indexes Message-ID: <20190912195622.GA29488@hjp.at> References: <20190912164105.GA17616@hjp.at> <3175.1568307295@sss.pgh.pa.us> <20190912190425.GA23651@hjp.at> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline In-Reply-To: <20190912190425.GA23651@hjp.at> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2019-09-12 21:04:25 +0200, Peter J. Holzer wrote: > On 2019-09-12 12:54:55 -0400, Tom Lane wrote: > > It's not taking the partial-index filter into account in that, I > > suspect, which skews the results in this case --- but that would be > > hard to account for accurately. >=20 > Hmm. Wouldn't that be a problem for partial indexes in general? They > usually cover only a small portion of the table and if the selectivity > is computed relative to the whole table the result may be way off. >=20 > I think it should be possible to adjust for a "WHERE column IS NOT NULL" > filter, because null_frac is in the statistics. For the general case you > would need an estimate of the number of rows covered by the index, which > I don't think we have. Looking through the source I see that the planner does estimate the number of tuples in the index. hp --=20 _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp@hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson --9jxsPFA5p3P2qPhR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAl16ot0ACgkQ8g5IURL+ KF17uA//YJqgds+tPePV8MJC6zpBh+/utDbhpndLXcohkG9lOAwpI4iCfUMGt1Uz iH06RmpvUi+jgPY4nzP3fOUTOD13DKJJXimywYWB/PaPVUYtCZhL93RLL4ZuvaIb vU2rHoIWyggh1fetpL9nmZFPXMiYkzRJpVUaKTMCCazpgcGeMxil/MdmiDTgJOqA eUjeyeKzv+QQZEszOVRmjnfWueQiB1bRgnpsRb+Oo4xsllZ1VFss5vRA+DWKGVrn 4WNrAk1bBhYKrS4ljb40z9nKH85vOvSDRPtOqSAYikal3oksI9ZBucDfHXGWf6E7 BeC5+8oVwnvKttgSB2O8kq+rvin533RoioitRSIxD3xc3rlLTz2vNFH33a2rTAnN bd4uX1E9pgdyxDUReMDX83JrRA9jSRUqmeHpbo4327c7r31Cc68eQ38Ne15mVO8B OQVMMSToIRYfDdmDKPJ3W+zkb0q6ONKjubX/85ROqhRS+a/x57/7N4rcNQ8KE1vF Eh9Ze9hnBNM7z4HGd5xug8B1VBBwF4+QYBZmGisGnwuiFqHIGDisu/gGiDzZEJxG 6u7xNMRPBVbGgCtZ+Ay1y40lqauUbCkq69Ae5UkIJdWQ0kp0B5xuzK18h1F4Fd0+ 70Jde5issnGwW2qiV58V1ZcJZz0c2EUSH9+Xnran+9RQ9CT1D08= =wmzL -----END PGP SIGNATURE----- --9jxsPFA5p3P2qPhR--