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 1swpEc-006ELk-RS for pgsql-general@arkaria.postgresql.org; Fri, 04 Oct 2024 20:49:11 +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 1swpEc-005vUV-5J for pgsql-general@arkaria.postgresql.org; Fri, 04 Oct 2024 20:49:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1swpEb-005vTf-QE for pgsql-general@lists.postgresql.org; Fri, 04 Oct 2024 20:49:09 +0000 Received: from fout-a5-smtp.messagingengine.com ([103.168.172.148]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1swpEX-002Z0n-SU for pgsql-general@lists.postgresql.org; Fri, 04 Oct 2024 20:49:09 +0000 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfout.phl.internal (Postfix) with ESMTP id A17B41380331; Fri, 4 Oct 2024 16:49:05 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Fri, 04 Oct 2024 16:49:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1728074945; x=1728161345; bh=mq55YQqSz0q0lClm47YqOu/VMw507RcSffHFwmO6eeA=; b= OzZT7zKlwGJxoJDw+v4u9FwgQR1HGT/peMw53CZmDRyVUJ1Hbs3N3rDiVJZMCdn1 q25v1IRtBnhxGTh6ZfCvJu5Bvf8xOEHGTrcLp8ZUS8KkeKt+bkNbjl1MYySdRdj6 13EQ9Qa0DhB/fUdzqC8exDn+TGXhSu7CyZaLzBQ68fbEGnPm8FVSLziRJc81/3lD Er9ios6Na8KLs1WwAzmtfcVYWyKGm9lUqSEfNHCVPRhxCh9p10XX0XTD/+VjymFN CtKcVD6p+vCHyVYyrdt6uvgqoTalXfacqVshC8SoAyfSh8vgx0vBcAz67/aAHQ/T j0XAqoaPKDI2YiQkgGUsSw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1728074945; x= 1728161345; bh=mq55YQqSz0q0lClm47YqOu/VMw507RcSffHFwmO6eeA=; b=X /I/NfctCuxZxdSEQYEry+2ViC0Dh7NhBCINuT3vrIFeJB6qGgKAWiuNAprrS41LF ++2Ufb+Jlv5Kn4Ajg4kxEFZPGpYL7b0TEV4k9Rsjd/f2ZJG2PjDuXOUZDDnlw540 HkzMH6A0U3O/ZtZXjqapvFCR5JXbB3NBcuEXMngepn6xo6PhnTOe3FIt4LsBjM5E MJsjwXGP9Hkljcw0Ka/KULycOkimY+zxyDzwKNLv4X5lbuZaXCi9snu+7qtn1lHf G72PXB79pkenBtvutoBTlvyG+s/duS89oa4wuw+/bq7VmIAyvFt+iTY2D3whO0bN 7+T0vGvsNChOmGdoX/8hw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddvfedgudehgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgg gfuffvfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhirghnucfmlhgrvhgv rhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrg htthgvrhhnpeffleegieefgfevudehtdfhkeeutdffjeevgeffgeejvedthefgudeiteef heejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmpdhnsggprhgtphhtthho pedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehlohhknhgrthhhrdejfeesgh hmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlsehlihhsthhs rdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Oct 2024 16:49:04 -0400 (EDT) Message-ID: <1dec4905-f6b7-4366-bdc0-fe1ce22bdacd@aklaver.com> Date: Fri, 4 Oct 2024 13:49:03 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: How batch processing works To: Lok P , pgsql-general@lists.postgresql.org References: <4178E73A-24F5-4E3C-92F6-1532D8102C3E@kleczek.org> <20240921143629.t2x37xfczeeunpnf@hjp.at> <20240922192321.kpbe3p4ixmoid3ma@hjp.at> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10/4/24 1:05 PM, Lok P wrote: > > > On Mon, Sep 23, 2024 at 12:53 AM Peter J. Holzer > wrote: > > > > Thank you so much. > > I was expecting method-3(batch insert) to be the fastest or > atleast as you said > > perform with similar speed as 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. > > > As in case of batch insert below is the fastest one as it inserts > multiple rows in one statement. Similarly I understand, Delete can be > batched as below. However, can you suggest how an Update can be batched > in a simple/generic fashion in JDBC for an input data stream with > multiple input values. As because for an update if we write as below , > it will just do one row update at a time? > > Update SET column1=?,   column2=?, column3=? where > =? ; UPDATE table_name SET column1 = vals.text_val, column2=int_val FROM (VALUES (1, 'dog', 23),(2, 'cat', 44)) AS vals (id, text_val, int_val) where table_name.id = vals.id; > > > INSERT INTO VALUES  (1, 'a'), (2, 'a'),(3,'a'); > Delete from where column_name  in (, > ,...); > > -- Adrian Klaver adrian.klaver@aklaver.com