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 1gUZ2O-0000BS-Jw for pgsql-general@arkaria.postgresql.org; Wed, 05 Dec 2018 15:24:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gUZ2N-0002ZY-A3 for pgsql-general@arkaria.postgresql.org; Wed, 05 Dec 2018 15:24:31 +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 1gUZ2N-0002ZL-1z for pgsql-general@lists.postgresql.org; Wed, 05 Dec 2018 15:24:31 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gUZ2K-0002ch-08 for pgsql-general@lists.postgresql.org; Wed, 05 Dec 2018 15:24:30 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id BC6AF5F7AA; Wed, 5 Dec 2018 10:24:26 -0500 (EST) Date: Wed, 5 Dec 2018 10:24:26 -0500 From: Stephen Frost To: Ron Cc: pgsql-general@lists.postgresql.org Subject: Re: surprising query optimisation Message-ID: <20181205152426.GE3415@tamriel.snowman.net> References: <03a0af57-3ebc-5501-10ef-6a639c7c34b8@withers.org> <20181128224950.GS3415@tamriel.snowman.net> <5d7f8d97-32f3-fd88-44cc-948673579a71@withers.org> <20181130153327.GA3415@tamriel.snowman.net> <20181205143853.GC3415@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="8IgpUc3zahWtfmuT" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --8IgpUc3zahWtfmuT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Ron (ronljohnsonjr@gmail.com) wrote: > On 12/05/2018 08:42 AM, Chris Withers wrote: > >On 05/12/2018 14:38, Stephen Frost wrote: > >>>>* Chris Withers (chris@withers.org) wrote: > >>>Interesting! In my head, for some reason, I'd always assumed a btree i= ndex > >>>would break down a char field based on the characters within it. Does = that > >>>never happen? > >> > >>Not sure what you mean by 'break down a char field'. > > > >Rather than breaking into three buckets ('NEW', 'ACK', 'RSV'), a more > >complicated hierarchy ('N', 'NE', 'A', 'AC', etc). >=20 > The b-tree indexes on legacy RDBMS which I still occasionally fiddle with > performs key prefix compression in a manner similar to what you refer to, > but otherwise that's not how b-trees work. There's been some discussion of prefix compression in PostgreSQL. Even with that, though, it hardly seems sensible to have an index which has tons of duplicates comprising most of the index, and a !=3D would still have to search the index to make sure there aren't any entries which need to be returned.. Now, maybe once we get skipping scans where we would be able to skip over a large chunk of the index because it's just tons of duplicates without having to visit everything along the way, then maybe having this inefficient index would "just" take up disk space, but why waste that space? Thanks! Stephen --8IgpUc3zahWtfmuT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJcB+2qAAoJEO1sijiDR2RVNJwP/RRhSadNrw4NzMTfuVHSr04w zakelMHJJ0K9ncUkItKus4L8s+gx4Mv2dSGFt/OIvKjyu5KDfDwdXO6N+CakBFwj Y4dAw9h6YVPVKV78CTtA7Jcn3tkVvAU69fcOY7WevHMAGAZmTMoVCH3KteAryyJM QIGOAgyukQb0DPogpKyd3p06YMWgXNHT+CpV+C7BeV6g5/4y53QEX4forYMSfXYM XQ3TlKA9EFAqGC9mJdkhTlo2kr8xhKeBIBJfRhjb/rIsWFEjs+/LbCW8yCGe5laC F/89K4QbjLGBpyVpIoCrQhtq7J2m03dO1i+46b9Ig93HTVXkqqd+1+X9TGVMlWkL rpcOCEL19A4AUjHZNHWJzRZpIDQunzf4BZywLh5cKm4OEilTeg7Wql85wBDNZvHA mRIS3e83/kYtpU31dYJ9JhfL7jCImY/SLiYfJlLCS5aXNs8Q5dUcPVq/zFTRjATk 57GrUuVrCb+8fJs4jY49vWOS7j/u6wkiNJGPYC8KsPwlIg4ntXttbjuSd+Uz3wPR l9hq4BSI35eqLpsB/GBi08EaogoMfro+SIiDoaojgmXZlynjsGuhmTjNvu5vFmfn s8ppCMY/QxVbvUluVVOluZfjmvVH17Yt43+6k0viYoPPfEJqluYgEs3eKQ7VFmZK ZM9soI7lQ6RdIOQsnVgt =iBdP -----END PGP SIGNATURE----- --8IgpUc3zahWtfmuT--