Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jhY3R-0007F6-2B for pgsql-novice@arkaria.postgresql.org; Sat, 06 Jun 2020 12:36:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jhY3N-0008Du-9b for pgsql-novice@arkaria.postgresql.org; Sat, 06 Jun 2020 12:36:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jhY3N-0008Dn-2f for pgsql-novice@lists.postgresql.org; Sat, 06 Jun 2020 12:36:01 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jhY3K-0006HX-2r for pgsql-novice@lists.postgresql.org; Sat, 06 Jun 2020 12:36:00 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id AA7745F7A5; Sat, 6 Jun 2020 08:35:56 -0400 (EDT) Date: Sat, 6 Jun 2020 08:35:56 -0400 From: Stephen Frost To: David Harrigan Cc: pgsql-novice@lists.postgresql.org Subject: Re: pages_in_range for BRIN index Message-ID: <20200606123556.GV6680@tamriel.snowman.net> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="RBdmpsAEjcqDYAXp" 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 --RBdmpsAEjcqDYAXp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * David Harrigan (dharrigan@gmail.com) wrote: > I'm having difficulty in trying to understand the value I should use for > `pages_in_range` when creating a BRIN index. I have data coming in, nearly > 3-4 > rows per second with an ever increasing `created` timestamp. Perfect for a > BRIN index to save on space :-). Yup, that does sound like the right use-case. > I gathered some data (at time of query) on the table I'm interested in: >=20 > Size (bytes): 16130588672 > Pages: 1969066 > Rows: 48215073 > Rows/Page: 24 Not quite there yet, but hopefully you're thinking about partitioning too. > At the moment, the column I'm indexing on, created, has a BTREE index on = it, > and it's over 2GB in size! Well, ok, sure, 2G isn't *that* big tho. :) > What would I need to do to go about choosing an appropriate value for > pages_in_range? Ok, so, this really depends on what queries you're running and how many rows you want to have to scan for them. If you're mostly doing 'bulk' kinds of queries that hit a lot of rows, then having a larger value is probably fine since you won't be going through that many rows that you have to throw away. On the other hand, if the queries that are using this index are just getting back a couple of rows as a result, then you probably want a smaller value, to make those queries be fast. Of course, the tradeoff here is in the size of the index- a smaller number means a larger index, and a larger number means a smaller index. If you're not sure though- try the default..? > Lastly, is it necessary to run a `vacuum analyse freeze` before/after > index creation? Nope. Thanks, Stephen --RBdmpsAEjcqDYAXp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJe242sAAoJEO1sijiDR2RVKL0P/3hagcHZwMm60GB22mMFEesj hmNsTBqu84jAvVaZRDmiC/z6QwNS+2PWHkL9vj2CrWUWyHI+SbFTYn5iYOweNLcU wNzbTguOH+IKp4AeyFe7NEKh8iKP+4Aa7ZeKBYCKDOAvSaalMuYOHZRE9xMdRnfa MhnmKfRvCzusWEsCHgyVgbfZV+U0RVTrq16mzewRjpDKdz9phdUKu2Ds9BOJgB7h 0uATVvnTvmsjBeUgI5Ck4mQzJyKuzNcNf6iaLj963pv3HD4W/LQtOWO/0oKB4oqz qsAkj1QI/vkXut5vTyPqUvlND8GSn2UTRZgCkAcM1OLMkFwnY/eT9yipDdSXDu+w 53M9qIHwAD0IhDLCL9nRVFxGGFYme1mEvQ+0tHXk4tmWQrhMSsrPSkzEPIj00UHo VRD18j/lxCC65Dpa7lRuK+3r7vKAj7Bwa0kxcEeJq94RqUimxOXfrnFAj7+7hF+2 aRfl+wro4yLTwP6/9LVx6AopKRw7DK3pg9yvpb+FaPGt21zKucwIzIwrfJ7TKQke NrkFpTceGwBrhKqxEFM6FGY3MtGB2cZhaljBZWFZfEhkdWixKXuDchPF6MOBZTuI F4+hNbBrUCSYp/BAoDCgpEnubZnMcTJYI6HXoKyjpC1XTpNFK6MqerC92AT8jHUO 6Ghe8yCJUmsBMWLuvrX1 =QJ6V -----END PGP SIGNATURE----- --RBdmpsAEjcqDYAXp--