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 1mv5Cj-00083T-IQ for pgsql-general@arkaria.postgresql.org; Wed, 08 Dec 2021 22:14:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mv5Ch-0005rW-BF for pgsql-general@arkaria.postgresql.org; Wed, 08 Dec 2021 22:14:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mv5Ch-0005rN-0h for pgsql-general@lists.postgresql.org; Wed, 08 Dec 2021 22:14:23 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mv5Cd-0000bp-DB for pgsql-general@lists.postgresql.org; Wed, 08 Dec 2021 22:14:21 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 3C67C5E1C; Wed, 8 Dec 2021 23:14:13 +0100 (CET) Date: Wed, 8 Dec 2021 23:14:13 +0100 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: performance expectations for table(s) with 2B recs Message-ID: <20211208221413.xfijsujafpvdp5c2@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="4yznanmjiknue6kn" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --4yznanmjiknue6kn Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2021-12-08 14:44:47 -0500, David Gauthier wrote: > So far, the tables I have in my DB have relatively low numbers of records= (most > are < 10K, all are < 10M).=A0 Things have been running great in terms of > performance.=A0 But a project is being brainstormed which may require som= e tables > to contain a couple billion records. [...] > What else should I be worried about ? >=20 > I suspect that part of why things are running really well so far is that = the > relatively small amounts of data in these tables ends up in the DB cache = and > disk I/O is kept at a minimum.=A0 Will that no longer be the case once qu= eries > start running on these big tables ? Depends a lot on how good the locality of your queries is. If most read only the same parts of the same indexes, those will still be in the cache. If they are all over the place or if you have queries which need to read large parts of your tables, cache misses will make your performance a lot less predictable, yes. That stuff is also hard to test, because when you are testing a query twice in a row, the second time it will likely hit the cache and be quite fast. But in my experience the biggest problem with large tables are unstable execution plans - for most of the parameters the optimizer will choose to use an index, but for some it will erroneously think that a full table scan is faster. That can lead to a situation where a query normally takes less than a second, but sometimes (seemingly at random) it takes several minutes - users will understandably be upset about such behaviour. It is in any case a good idea to monitor execution times to find such problems (ideally before users complain), but each needs to be treated on an individual basis, and sometimes there seems to be no good solution. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --4yznanmjiknue6kn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmGxLjAACgkQ8g5IURL+ KF0TQA//R5+mWoHsywu/nA+q7GOTgbrm127dtVUCjS69y9QLCkXIBvtkUH82FvRh cHP7omy9EFzgmafnUh62g8VV9v/aG25vDndx13sY4GoID2k4DnNXCYSJpppVppHa 9iWC0IRwIeMsoUsycjHuvh5SHgbV21g7UVVSrxUsangvZz33mKMUj1MGKSFz7+3R bhaJQHtBB0ikPDGxyllDl52t9WfFzB8lvBoonQk37g7Ll0zAx3PiJvgpAQSjSmtD w4ZuvqGj9YjikM02t9Jye7SVi5n6rhDeOIbWe3XP2Azqs3p2hCZ7McrOAwjAil6T fsU2t8XDvpAV+iv2jbBCw6+asjZUSHkAASqCu9WckEUJyaGBviKW8YZ9rxHqg6w/ rZqbW8G3+qlCy60DCEYhgCNefG2dmFR+aFC53iO79WMTEKAfty2iaAkdorSHMASo ZtNhtBFdRpJryR2Vo13IqpWsx5/ta5DerXKDm0lb9KiBMlErMXOemcc61/e+5pty yIRcff5XkC9+lY/0xhtMQf/7bI+e6J3W1vJeQW0J5hNNSm5n/SF3khMDlVsMd0tW pzvnlq0SvfUEjhKBs+rvAtyIOvtNFVgNGjOUAqAyPm6blD2i99IuNLFi/68ouGAw NLPeax337SsgDZ1BeIzzUqY7t4NrzTXXjAuqLzZeBST85u58cjQ= =gUpd -----END PGP SIGNATURE----- --4yznanmjiknue6kn--