Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpIeK-0004qO-Bf for pgsql-performance@arkaria.postgresql.org; Wed, 28 Sep 2016 17:28:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bpIeJ-0004if-Uo for pgsql-performance@arkaria.postgresql.org; Wed, 28 Sep 2016 17:28:03 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bpIeJ-0004iG-5G for pgsql-performance@postgresql.org; Wed, 28 Sep 2016 17:28:03 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpIeG-00079r-G3 for pgsql-performance@postgresql.org; Wed, 28 Sep 2016 17:28:01 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id BCADF5F79A; Wed, 28 Sep 2016 13:27:59 -0400 (EDT) Date: Wed, 28 Sep 2016 13:27:59 -0400 From: Stephen Frost To: Greg Spiegelberg Cc: Mike Sofen , "pgsql-performa." Subject: Re: Millions of tables Message-ID: <20160928172759.GW5148@tamriel.snowman.net> References: <002d01d218d1$41bb2160$c5316420$@runbox.com> <003401d218d5$cb900640$62b012c0$@runbox.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ECAkxgSy0pGoHfdA" Content-Disposition: inline In-Reply-To: X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.13.0-91-generic (x86_64) X-Uptime: 13:09:56 up 81 days, 18:34, 16 users, load average: 0.26, 0.16, 0.15 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -4.9 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --ECAkxgSy0pGoHfdA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Greg, * Greg Spiegelberg (gspiegelberg@gmail.com) wrote: > Bigger buckets mean a wider possibility of response times. Some buckets > may contain 140k records and some 100X more. Have you analyzed the depth of the btree indexes to see how many more pages need to be read to handle finding a row in 140k records vs. 14M records vs. 140M records? I suspect you'd find that the change in actual depth (meaning how many pages have to actually be read to find the row you're looking for) isn't very much and that your concern over the "wider possibility of response times" isn't well founded. Since you have a hard-set 30ms maximum for query response time, I would suggest you work out how long it takes to read a cold page from your I/O subsystem and then you can work through exactly how many page reads could be done in that 30ms (or perhaps 20ms, to allow for whatever overhead there will be in the rest of the system and as a buffer) and then work that back to how deep the index can be based on that many page reads and then how many records are required to create an index of that depth. Of course, the page from the heap will also need to be read and there's a bit of additional work to be done, but the disk i/o for cold pages is almost certainly where most time will be spent. I suspect you'll discover that millions of tables is a couple orders of magnitude off of how many you'd need to keep the number of page reads below the threshold you work out based on your I/O. Of course, you would need a consistent I/O subsystem, or at least one where you know the maximum possible latency to pull a cold page. Lastly, you'll want to figure out how to handle system crash/restart if this system requires a high uptime. I expect you'd want to have at least one replica and a setup which allows you to flip traffic to it very quickly to maintain the 30ms response times. Thanks! Stephen --ECAkxgSy0pGoHfdA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJX6/2fAAoJEO1sijiDR2RVNHMQAMB8YT3xnGAXMWLbndXCUKPn tqrssNwxd6F6C7bt1/ZPdbG32TE4dS65Kzyz4sisPdmOWYVoKAZ4sCUSmEhEXwn1 JcXLTfJ48BYknZxqw96cJdwJet2fNadY01jCQGioRU/SdTB6K0HZzP/H+8DCdX+4 tLaL2lRb9BcS6iIzll4dRbBa7hRR65JIY7d2m9I2B9MONIqRAc66Uf+1PW/Ag9Hf PsageZxHWfOr4dmMfmIzRz5zmnzVwu1WujxJfJ3I60xy5CJYLpmXTRMvVTOroUAN ciJjW+++M60EuDebiSKoybdEcGyWvf+tHR3IwTp7k5MTLggasEVfDIc7QmMowLBS 26LSBRK93go0L2gGOHqtPGyr2t+1d0nUMYca9JMTFe83L8inEo963qbVo97hXHBN X9a9JKvtV8oEIBBrP/Bucohm2cZBzKO9ilRjwehwu0jYgVbNmg7rY2f+K9ux3R/q tY16Q5HISHmm7XWs+PQZnTkyAVNLzpDUNggvEUgo45YfXY2KfCkwckDx2V5BkPrN /rQab4pnGRnLo9iKrPsIbFy7O+ImhOCxIyswtdZReeX7kcjCLUF5RA5zqtyeAlyu qdDea+18dM53JB2bNoqgsKdypW9p94OYw3IXou3WT+vCU7QkQ+5EZ0Ax6MGg5KyP fbPqEoueVvB4BE/yhCvz =5YTl -----END PGP SIGNATURE----- --ECAkxgSy0pGoHfdA--