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 1sr1LC-00Eu97-M0 for pgsql-general@arkaria.postgresql.org; Wed, 18 Sep 2024 20:31:58 +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 1sr1LA-00FFQg-Po for pgsql-general@arkaria.postgresql.org; Wed, 18 Sep 2024 20:31:56 +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 1sr1LA-00FFOe-DB for pgsql-general@lists.postgresql.org; Wed, 18 Sep 2024 20:31:56 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sr1L7-001sfe-RU for pgsql-general@lists.postgresql.org; Wed, 18 Sep 2024 20:31:55 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a86e9db75b9so10025266b.1 for ; Wed, 18 Sep 2024 13:31:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726691513; x=1727296313; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Bb1tcB/i4U0l2fZdlYZKNP69y5VmibjLVHaPtWscYxM=; b=aTOfQtZju7NVgVZpAuE/TagR41YTLlXwHAfyGoymPW6nkgWu4s+iCmwiA+xOIyEx3r 07IczgOYOsuYu3nSfjP6WnGeX/nFkhFXgkDW+nrpMatTyRaDGfYv6mSoj5fFuncWawL6 JfypOCu3iSwxP5Pe+RAvMMlxMBV9sVmkHLUKX9OJgDa3wm6wH47EjBlV2Pil9h60Rv0k Y9kv3smrfpOnVW5Eb/ceOsBdVLVX6TMUtZp5+jTg8sMflrOag0AVBh+iiYFO5hrQEY+3 EajPODZBODUWzlClPJZdzmeDeN5WMWnanX99SlV4Np0MdCSFiBeG5SUfH0V0uxHrRslW qIRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726691513; x=1727296313; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Bb1tcB/i4U0l2fZdlYZKNP69y5VmibjLVHaPtWscYxM=; b=LlRkJy5Z/nOZCHF3MNd5+VR6moDvpoZtQId+qWRFQ42GdoMUlYdDJMXgspvaOGhnS3 Da/hcLkk+H2aY4+Y1SdKbfmndX/BB+8AtQGOuiCQLwLY5FiL3j7ZLT/yeySQOmA+/4t2 nl5XAmbtdqz5OV5/06H+HzNbyL3GJxlEzqiOSi5r79TFB67ruJloddkJh41Vb7WHvXes O7UWF7b76DXiishbvVjEOGTcJI8tE9PAvL7qWEL9MPvOxUs4OTl29EWWiS5AYTccKbNL uEQX/kf3yBOXIeLxH5bwlXdoEr5i+QIhhSLhn0obn2hVDoHnR/8hMs0D2TPSV3x+tAWx t6fA== X-Forwarded-Encrypted: i=1; AJvYcCVunkPFlLZPiJYyHcjlIL/E8rsIkASYqPPDr8USlkn/zRflUo3c9qVaa51CZOYPftNkTrS8t4tbY6qNG9Pi@lists.postgresql.org X-Gm-Message-State: AOJu0YwoXFc3zYLHBGwQ6CBzfDFjQOwA98uryNoAFPq8NkEZJRKZPuli W530YjjTOOI75UB0EM1E1Sm+/2T19smNX3Y0ElzsCT6OQaI8INMS3VDmFTKN5ZdqTnSrWgwAMye 2DfxhsJ4Mx9ALhhjPutdomdAFCO4= X-Google-Smtp-Source: AGHT+IHk2dwpG5bAzulBCyVYwgOuaDid14HsjjuLRYx8NStNr7JynBg2bbsdgID90g+JIR0J0sQFx+IpMpnH3B5R0aY= X-Received: by 2002:a17:907:efc7:b0:a8d:439d:5c25 with SMTP id a640c23a62f3a-a90294a881amr2508568866b.4.1726691512607; Wed, 18 Sep 2024 13:31:52 -0700 (PDT) MIME-Version: 1.0 References: <3dddea5e-52ab-4075-970d-a87b0c921ae7@aklaver.com> <225d1bc1-5117-4c72-85a1-bac6355fb659@aklaver.com> In-Reply-To: From: veem v Date: Thu, 19 Sep 2024 02:01:39 +0530 Message-ID: Subject: Re: IO related waits To: Adrian Klaver Cc: Greg Sabino Mullane , Christophe Pettus , pgsql-general Content-Type: multipart/alternative; boundary="0000000000003ee94f06226ab2cb" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000003ee94f06226ab2cb Content-Type: text/plain; charset="UTF-8" On Wed, 18 Sept 2024 at 05:07, Adrian Klaver wrote: > On 9/17/24 12:34, veem v wrote: > > > > It does if autocommit is set in the client, that is common to other > databases also: > > https://dev.mysql.com/doc/refman/8.4/en/commit.html > > > https://docs.oracle.com/en/database/oracle/developer-tools-for-vscode/getting-started/disabling-and-enabling-auto-commit.html > > > https://learn.microsoft.com/en-us/sql/t-sql/statements/set-implicit-transactions-transact-sql?view=sql-server-ver16 > > You probably need to take a closer look at the client/driver you are > using and the code that interacting with it. > > In fact I would say you need to review the entire data transfer process > to see if there are performance gains that can be obtained without > adding an entirely new async component. > > > You were spot on. When we turned off the "auto commit" we started seeing less number of commits as per the number of batches. However we also started seeing deadlock issues. We have foreign key relationships between the tables and during the batch we do insert into the parent first and then to the child , but this does happen from multiple sessions for different batches. So why do we see below error, as we ensure in each batch we first insert into parent and then into the child tables? caused by: org.postgresql.util.PSQLException: ERROR: deadlock detected Detail: Process 10443 waits for ShareLock on transaction 220972157; blocked by process 10454. Process 10454 waits for ShareLock on transaction 220972155; blocked by process 10443. Hint: See server log for query details. Where: while inserting index tuple (88736,28) in relation "TAB1_p2024_08_29" --0000000000003ee94f06226ab2cb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Wed, 18 Sept 2024 at 05:07, Adrian Kla= ver <adrian.klaver@aklaver.= com> wrote:
On 9/17/24 12:34, veem v wrote:
>

It does if autocommit is set in the client, that is common to other
databases also:

https://dev.mysql.com/doc/refman/8.4/en/commit.ht= ml

https://docs.oracle.com/en/database/oracle/develop= er-tools-for-vscode/getting-started/disabling-and-enabling-auto-commit.html=

https://learn.microsoft.com/en-us/sql/t-sql/statements/set= -implicit-transactions-transact-sql?view=3Dsql-server-ver16

You probably need to take a closer look at the client/driver you are
using and the code that interacting with it.

In fact I would say you need to review the entire data transfer process to see if there are performance gains that can be obtained without
adding an entirely new async component.



You were spot on. When we turned off t= he "auto commit" we started seeing less number=C2=A0of commits as= per the number of batches.=C2=A0

However=C2=A0we = also started seeing deadlock issues. We have foreign key relationships betw= een the tables and during the batch we do insert into the parent first and = then to the child , but this does happen from multiple sessions for differe= nt batches. So why do we see below error, as we ensure=C2=A0in each batch w= e first insert into parent and then into the child tables?

caused by: org.postgresql.util.PSQLException: ERROR: deadlock dete= cted
=C2=A0 Detail: Process 10443 waits for ShareLock on transaction 220= 972157; blocked by process 10454.
Process 10454 waits for ShareLock on t= ransaction 220972155; blocked by process 10443.
=C2=A0 Hint: See server = log for query details.
=C2=A0 Where: while inserting index tuple (88736,= 28) in relation "TAB1_p2024_08_29"
--0000000000003ee94f06226ab2cb--