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 1gUYFL-0006Tv-Fd for pgsql-general@arkaria.postgresql.org; Wed, 05 Dec 2018 14:33:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gUYFI-0005ST-Lj for pgsql-general@arkaria.postgresql.org; Wed, 05 Dec 2018 14:33: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 1gUYFI-0005SF-AX for pgsql-general@lists.postgresql.org; Wed, 05 Dec 2018 14:33:48 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gUYFB-0006Gb-9z for pgsql-general@lists.postgresql.org; Wed, 05 Dec 2018 14:33:46 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 776915F7AA; Wed, 5 Dec 2018 09:33:40 -0500 (EST) Date: Wed, 5 Dec 2018 09:33:40 -0500 From: Stephen Frost To: Thomas Kellerer Cc: pgsql-general@lists.postgresql.org Subject: Re: surprising query optimisation Message-ID: <20181205143340.GB3415@tamriel.snowman.net> References: <03a0af57-3ebc-5501-10ef-6a639c7c34b8@withers.org> <20181128224950.GS3415@tamriel.snowman.net> <5d7f8d97-32f3-fd88-44cc-948673579a71@withers.org> <076fec6e-3bb4-3a99-e71f-dc1cec684cb6@withers.org> <4b68075c-55b0-e937-f794-125251573011@gmx.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="waELlFB4HDL0UWTv" Content-Disposition: inline In-Reply-To: <4b68075c-55b0-e937-f794-125251573011@gmx.net> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --waELlFB4HDL0UWTv Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Thomas Kellerer (spam_eater@gmx.net) wrote: > Stephen Frost schrieb am 30.11.2018 um 14:05: > > PG doesn=E2=80=99t know, with complete certainty, that there=E2=80=99s = only 3 > > values. > =20 > Would the optimizer consult a check constraint ensuring that? Not today, I don't believe (haven't looked at the code though, to be fair), and seems like it'd be an awful lot of work for a rare use-case that would be better with just a partial index.. What we will do today is if you ask for a specific value and there's a CHECK constraint which lists out specific values and that value isn't among the set, then we'll just skip over the table (One-time filter: false), thanks to constraint exclusion. Thanks! Stephen --waELlFB4HDL0UWTv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJcB+HEAAoJEO1sijiDR2RVBGcQAISZL/4nEvGui+0lRcf4Jlcc dXBrz+5buzges+VJqcEZBq+t3FfmX4KuRHtzcJ30LZfY/FgGNUZgVeduKm1KKA8K TRtz8M5RwDXjy9iUxLQ/9cmCP0LMSz8MpTSXr4qO1QGkPyXN+dGZF50YT2VdXAmk k+LPDuDdUEVpcXIQhKkS51SXMIyEsHX5mVw2KhVoh3W1pTnI6N5JzP5MyYr2l0Gz EJEQMWICVYk8cz+Z1SzvPj9BNfx5gKV4UTnzEMtewhDjxS5DRoLgknoNolYt4+ay lx06XKgqxzgJc0Qau0hZicfuPTXoEkcuE/7fvYl2mQdW7jewUXcr36iyTL7cPD/+ Ull8Qrdse7gsjBxsYs3jNSHwnO/tWcR+TFw3G7z2R/68KtP1JvQ9L+Mz2u9+hd4x JcS3jGAodon3UA+t9T2rKlRU/g2j4H64eR0EexSTNemqP+sctxuojny6CxYTHOUV sB1QiNP6MQmh1iGPb+Ax5J2c5WXjklR9d+9Q42+gBu/smb2EqV0R88YbzEZnaRWm M8w8CkdkgElpqBhBYbDSBe7alJJkTdApC4DYBOCfe0Y7pdsgKfuZhItMiJuK7JYr 6JXu3TzjhmbCzjQ5HvEJo7YKslNZ4S/5IpERI5LpXiW3HQuGKdBShXDTdGQQHEEa T7HUzZ6j7rUn8s4Q97zn =Xntv -----END PGP SIGNATURE----- --waELlFB4HDL0UWTv--