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 1hSMQb-0001X1-2O for pgsql-general@arkaria.postgresql.org; Sun, 19 May 2019 14:04:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hSMQZ-0000gt-3X for pgsql-general@arkaria.postgresql.org; Sun, 19 May 2019 14:04:39 +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 1hSMQY-0000d8-No for pgsql-general@lists.postgresql.org; Sun, 19 May 2019 14:04:38 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hSMQW-0000mc-74 for pgsql-general@lists.postgresql.org; Sun, 19 May 2019 14:04:38 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 8BA8E5F79F; Sun, 19 May 2019 10:04:34 -0400 (EDT) Date: Sun, 19 May 2019 10:04:34 -0400 From: Stephen Frost To: "Peter J. Holzer" Cc: pgsql-general@lists.postgresql.org Subject: Re: bigint out of range Message-ID: <20190519140434.GG6197@tamriel.snowman.net> References: <20190518093519.2kd6hyw37wcx6qwc@hjp.at> <20190518192703.ml6duizgdyfyetva@hjp.at> <20190518204941.d2o5xy2b53r266ws@hjp.at> <55d8ce6e-2a94-1003-0fc1-66a39d6d2e8a@gmail.com> <20190518223952.g5jrsyj5us7kytpb@hjp.at> <0bea576e-43df-9176-a5da-1aea2bb1b337@gmail.com> <20190519104352.fty5grjwrsj5p4zp@hjp.at> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="y4kreuXC77SOBB43" Content-Disposition: inline In-Reply-To: <20190519104352.fty5grjwrsj5p4zp@hjp.at> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --y4kreuXC77SOBB43 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Peter J. Holzer (hjp-pgsql@hjp.at) wrote: > On 2019-05-18 19:16:19 -0500, Ron wrote: > > > If the the table fills up, you increase nr_buckets, reallocate and > > > rehash all entries. > >=20 > > Ouch.=A0 Response time on a big table would take a serious hit if that = rehash > > happened in the middle of the day on a big OLTP system. As noted below, that isn't actually how it works with PG's hash indexes. > So that might be a reason not to use hash indexes tables where the worst > case insert time is a concern (the average insert time is still O(1)). The worst-case insert time is certainly worse than the average but it's not nearly as bad as being imagined here. > You can split buckets lazily, and in fact PostgreSQL does this. I just > looked at the code briefly, but I don't really understand how it works. > Guess I would have to read Margo Seltzer's paper paper for that. >=20 > Still, even with that optimization (or tradeoff - it may make the lookup > slower) the README notes that splits are expensive. There's multiple different levels, really, from "best case" where the new item can just be placed directly on to a page that has free space, to "slightly worse case" where an overflow page has to be added, to "even worse case" where a prior page split has to be finished, to "probably worst case" where a full page split has to happen. There might even be some pathological cases where a prior page split has to be finished and then an overflow page has to be added and then another page split has to be done, or some such. Even so, for equality-based lookups (where the data set has few or zero duplicates), hash indexes can work quite well, but it's of course good to understand that inserts aren't always going to be exactly the same speed every time. Thanks, Stephen --y4kreuXC77SOBB43 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJc4WJyAAoJEO1sijiDR2RVc34P/ApYBvVlJkiIeOr3rrsEy31K O1oiGVtsjZiMOz5z4duo3MpLwIfNfqrfbBhl0seNG6Xp4lSrfgKMnDAR2dsvl5tY v3gM6svqJjugXw92RyZzHZAra2Z8gyG/AX5hvMQzMBhIdnY8NDOZ+TlhC2W/5itN jZNRRpzjFNPAgK/F2brBI//fgVMLLLyPOWnlCJTrooOPEtfftCYQ8I3Pv+I3gZef MFJq0klVaTIIMeJrUWjz/PYsS1GkFJ0DxEKSIx3TFPHRtR9HYIRvgQiVICdjYEtl jW/aspK4GuNZZTt2NcLPWAi7vYSfKORcct/Q3O+iNk0y0IVvQLDC+Y/RsIzlhgO9 9rK5jlvlgViyGZ+rBHFM2UZZxMXXR4MJ+XpBHDokTH67pqnpHcsCfgVJ6RXTvLS0 rOAc4H7Rc+yAXBwHyF6iHFvjh8jwdOKGnxlzrdjJ945h+pYnXWaokxEzLxyhIDdU EuQGWqVP4tzuOvrOquzxIGstqcBlzS01YIXuIj8XLWcdXo2VRWzgnOZ9T5qisaqX eKt7yJYJM/XL4onO1ZelHt7y9dd2BevlzYe4JICQB7CzcyvHIOzWPOMeGWscSZk5 jZtYzcoavGNsw12gUg+NUh8OapsM5QwPf0Nzo1AwCpLEaDN4g8i1SO31gv6EuZaA qpZovNU+6NnR8s498GsL =jCVK -----END PGP SIGNATURE----- --y4kreuXC77SOBB43--