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 1gg9mu-0005fu-8o for pgsql-general@arkaria.postgresql.org; Sun, 06 Jan 2019 14:52:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gg9ms-0000rj-UF for pgsql-general@arkaria.postgresql.org; Sun, 06 Jan 2019 14:52:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gg9ms-0000rW-Hv for pgsql-general@lists.postgresql.org; Sun, 06 Jan 2019 14:52:26 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gg9mm-0007Ot-0D for pgsql-general@lists.postgresql.org; Sun, 06 Jan 2019 14:52:25 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 49D662250; Sun, 6 Jan 2019 15:52:17 +0100 (CET) Date: Sun, 6 Jan 2019 15:52:17 +0100 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Is there something wrong with my test case? Message-ID: <20190106145217.7fxllfdeksgwvo35@hjp.at> References: <20181225115411.Horde.5fRj7BmRS_7UIgfoBa9Vz2w@webmail.gelassene-pferde.biz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gugpy7icqbvtvtei" Content-Disposition: inline In-Reply-To: <20181225115411.Horde.5fRj7BmRS_7UIgfoBa9Vz2w@webmail.gelassene-pferde.biz> User-Agent: NeoMutt/20170113 (1.7.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --gugpy7icqbvtvtei Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2018-12-25 11:54:11 +0000, Thiemo Kellner wrote: [three different but functionally equivalent queries] > Explain analyze verbose showed for: > A (cost=3D264.72..626.97 rows=3D31 width=3D90) (actual time=3D1.117..1.11= 7 rows=3D0 > loops=3D1) > B (cost=3D264.72..974.25 rows=3D31 width=3D58) (actual time=3D1.508..1.50= 8 rows=3D0 > loops=3D1) > C (cost=3D0.42..611.19 rows=3D31 width=3D52) (actual time=3D2.217..2.217 = rows=3D0 > loops=3D1) >=20 > I am very surprised that the cost of A is (much) higher than that of C wh= ich 626.97 doesn't seem "much higher" to me than 611.19. I would call that "about the same". > I suspected to be the most inefficient. I was that much fixed on the costs > that I initially ignored the actual time where my assumptions on efficien= cy > are reflected. Funny though is that the subjective impression when waiting > for the update queries to complete was that C was fastest by far, followed > by B and only at the end was update A. This is weird. C takes almost exactly twice as long as A, and while humans aren't very good at estimating times, One second should feel faster than two, not slower, and certainly not slower by far. Is it possible that your subjective impression wasn't based on the executions you posted but on others? Caching and load spikes can cause quite large variations in run time, so running the same query again may not take the same time (usually the second time is faster - sometimes much faster). hp --=20 _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp@hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson --gugpy7icqbvtvtei Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAlwyFhwACgkQ8g5IURL+ KF0MRA/+JfclzyBL0WiGhcoxpvNUtg1sLoPcBT91KFgzST7Kd9M+8Dwz7y12p6E2 0926nPLAd7xtzZAk1BXruZMDLEQsty7QirYbXnl/ZPyG8lGMlisbByNJ5d5uMQLi J0IwgrqfGWdM5kSCzA8lWYye+bIwEA1XvAYtAHmYJTI4wVi65niDp5q9Bs/ddt5E GtubDmROPuu+AO5v8+dN7lF1QpNWJCjlj4oJS5xmwDmBNgu/LVF/UrUIQiUdo8aG LVHg0U+NNLLISBFKPsojIyMO+tXiFT2FKOBRLV76Kcqz4DHS0tEXXY/dXl6AgJbs UMpA56E7IbKTF0D4TrkKMiI0QuJvbu3cHJn7Urh+9FOKAalptm/3/kGVEDrMjs9R 9qvqvKI6B/8Oxq75imrVFRgdsqlor1DyQyrdEY7zrJP6ztOCnoHkJwHp8yWFalT+ A1EhBiTM+JiHVxW1JxayhAfUU/dLU/VjKKXQZl/X6oSGKRj05ljR/nzTgCms2WEG ODC1Ey+7+xdwVwj3BHC3rOl2kbU0xWlIhj0rcaPtGeNVd/VIYcKYEh1VvhTd7g4x VCygNKpLDKddXx3oaKYD0VmZbt1i0aMLqUQi13xlHZSRb/dYq/O6LoqpAU/rvxL9 qh+A/iO8nnUDMlgIc2ePojcgwPuZ7TR/DaJODC8MVA3jrBtyl+o= =ANrS -----END PGP SIGNATURE----- --gugpy7icqbvtvtei--