Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ssSBC-008WfY-2y for pgsql-general@arkaria.postgresql.org; Sun, 22 Sep 2024 19:23:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ssSB9-00Azui-Ot for pgsql-general@arkaria.postgresql.org; Sun, 22 Sep 2024 19:23:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ssSB9-00Azua-ET for pgsql-general@lists.postgresql.org; Sun, 22 Sep 2024 19:23:31 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ssSB3-000Wfq-8E for pgsql-general@lists.postgresql.org; Sun, 22 Sep 2024 19:23:30 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id AB37C1DF98; Sun, 22 Sep 2024 21:23:21 +0200 (CEST) Date: Sun, 22 Sep 2024 21:23:21 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: How batch processing works Message-ID: <20240922192321.kpbe3p4ixmoid3ma@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: <4178E73A-24F5-4E3C-92F6-1532D8102C3E@kleczek.org> <20240921143629.t2x37xfczeeunpnf@hjp.at> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2ehsvvtvsiflntfi" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --2ehsvvtvsiflntfi Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2024-09-21 20:55:13 +0530, Lok P wrote: > On Sat, Sep 21, 2024 at 8:07=E2=80=AFPM Peter J. Holzer wrote: [... lots of code elided. method2 used 1 insert per row, method3 1 insert for 50 rows ...] > On my laptop, method2 is about twice as fast as method3. But if I > connect to a database on the other side of the city, method2 is now m= ore > than 16 times faster than method3 . Simply because the delay in > communication is now large compared to the time it takes to insert th= ose > rows. >=20 >=20 >=20 > Thank you so much. > I was expecting method-3(batch insert) to be the fastest or atleast as yo= u said > perform with similar speed=C2=A0as method-2 (row by row insert with batch= commit) Oops, sorry! I wrote that the wrong way around. Method 3 is the fastest. I guess I meant to write "method2 takes about twice as long as method3" or something like that. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --2ehsvvtvsiflntfi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmbwbqMACgkQ8g5IURL+ KF1GoRAAj0hqnDII/mu3pn+drEDHpNizMQeSCw+z99qsMBOJiEIoOcRIVELRlDU1 EepfieIbiTH0F9D29LsJnGyOUHGVFTuB9S4XiADlzOjJiJt+P9+aPiLBuNcTo+jZ lxYdJJXVU7gVy2l9OOfyWor9d5rruv/wGgQzBxYY7gTodXVs91JHBqVki5wM+jab uBbdLIVzXJA7l5XfQThZF6lbOkzNg0CHWl034abI314phzgR1UxemVNWKX/S8jiM qm9e5xqMTTTFba27ShF99NFL3gQNUkvnMx5mg7bhUxaHcRR1rfIBDmNUjwBy3l5K 0PqvPekryr8r6F5jqZTr+PQElJeNXh0i4sw/kgkYRzaHSt9dluVnS3OPSiNdps4N NcJtoGm+EbaJm2MYH8z9ySK5eaFtUJBuTEBO7OP//X/Zi2Myd9zP2yHzF+/xQECf GCQYaDZpcpU17wzqP9p5hxPtv8SxDOHuI4yZuEfOF+aGgJVJkBGuPull8K5i9bl3 s8zpzl7ZfCFSqC2H+/GlSP148Y/xLD1tRF1LEKrQ7Z8J5At6gvwxIlTP1EwZoSVC 5fIDE21JF7HcbDrkaq5sewYPUJTtIBCCTInerdxHglnH6gcEpVbdgTyZPaKtPZCn iPtANN8upTHlazFb8WkNQbJgYsMCuetDh0hVudh6mLbTHIR7Nto= =g7CT -----END PGP SIGNATURE----- --2ehsvvtvsiflntfi--