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 1sqhlJ-00C1ug-0J for pgsql-general@arkaria.postgresql.org; Tue, 17 Sep 2024 23:37:38 +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 1sqhlI-000AC2-Hr for pgsql-general@arkaria.postgresql.org; Tue, 17 Sep 2024 23:37:36 +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 1sqhlH-000ABu-Ki for pgsql-general@lists.postgresql.org; Tue, 17 Sep 2024 23:37:36 +0000 Received: from fout3-smtp.messagingengine.com ([103.168.172.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sqhlC-001itc-Uc for pgsql-general@lists.postgresql.org; Tue, 17 Sep 2024 23:37:34 +0000 Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 671951380233; Tue, 17 Sep 2024 19:37:30 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Tue, 17 Sep 2024 19:37:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc: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=fm3; t=1726616250; x=1726702650; bh=+k8qHFNz+m261DwPrjSfOfQ9xv/SUtifojLYYqCVA/k=; b= YmDlu5dzp1m79ieNRfzWXxd3tEQme9XbswFGonBrWAC91qDsltRkW5uZbPr70RHp iRxfhKxKKvTuLsj6pCDpYh2GWDq/rfWbLBV2XGPdR1vKWvBzjmOMO291aXfbklKR 6j4p49h4+vE9kBha3nfwPNfUZ8cLENxrrlithv5QKeRAzD52SYQPvk1OoNMQOZ4h bbIjySTAUyzFYkHPaPgHT2SSXQVOvwKvNah7KESpsHlKdI+14YWinddQG4AfNwxZ YjSV9ICt/N4w90Q6PJ561vp657ImtK3CT82RRgs4vJGZ8sEAJzkcwUgMAfzEZhLG BRX2zTPlzuxCzF0vV6W+xA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm1; t=1726616250; x= 1726702650; bh=+k8qHFNz+m261DwPrjSfOfQ9xv/SUtifojLYYqCVA/k=; b=A L5EmH0N7cnkgc6XHTu2oLErWhyj83njiDR877wAlQzK+irDSpTqRE37ef83iyLY2 c1umHvrnL4t3E8hnwCJh8DqprxZsYfd6M/HN6msbDQ5JGBMsy+0/8MEDoc6O3c4O t736+x97MT+cTlSEJU4qCZrj5dL3TsyXw2vjU9qsrupdqINmMQINElw+grWcv7R4 xu3ggUpgdl/p/etvTdaYIWrLlYzg7ciDpFK/jOsBJbECNVi3KY32RCA4chTnIF7Y min8djYRqd2rCZDhzwuM+zBlTbeBlJ+ehKVaaSHLsiRF3KMM7cDhQbSVuZRclTYj bCQrX6KTNUVVwXyQfNBYw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudekkedgvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdej necuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrh esrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhephfetvdefleetveffffdu ieefkedtueeluedvfeevieeiveegkeevjefghffglefhnecuffhomhgrihhnpehpohhsth hgrhgvshhqlhdrohhrghdpmhihshhqlhdrtghomhdpohhrrggtlhgvrdgtohhmpdhmihgt rhhoshhofhhtrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgs pghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepvhgvvghmrg dttddttdesghhmrghilhdrtghomhdprhgtphhtthhopehhthgrmhhfihgushesghhmrghi lhdrtghomhdprhgtphhtthhopeigohhfsehthhgvsghuihhlugdrtghomhdprhgtphhtth hopehpghhsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhr gh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 17 Sep 2024 19:37:29 -0400 (EDT) Message-ID: Date: Tue, 17 Sep 2024 16:37:28 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: IO related waits To: veem v , Greg Sabino Mullane Cc: Christophe Pettus , pgsql-general References: <3dddea5e-52ab-4075-970d-a87b0c921ae7@aklaver.com> <225d1bc1-5117-4c72-85a1-bac6355fb659@aklaver.com> 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 9/17/24 12:34, veem v wrote: > > On Tue, 17 Sept 2024 at 21:24, Adrian Klaver > wrote: > > > Which means you need to on Flink end: > > 1) Use Flink async I/O . > > 2) Find a client that supports async or fake it by using multiple > synchronous clients. > > On Postgres end there is this: > > https://www.postgresql.org/docs/current/wal-async-commit.html > > > That will return a success signal to the client quicker if > synchronous_commit is set to off. Though the point of the Flink async > I/O is not to wait for the response before moving on, so I am not sure > how much synchronous_commit = off would help. > > >  Got it. So it means their suggestion was to set the asynch_io at flink > level but not DB level, so that the application will not wait for the > commit response from the database. But in that case , won't it overload > the DB with more and more requests if database will keep doing the > commit ( with synchronous_commit=ON)  and waiting for getting the > response back from its storage for the WAL's to be flushed to the disk, > while the application will not wait for its response back(for those > inserts) and keep flooding the database with more and more incoming > Insert requests? My point is this is a multi-layer cake with layers: 1) Flink asycnc io 2) Database client async/sync 3) Postgres sync status. That is a lot of moving parts and determining whether it is suitable is going to require rigorous testing over a representative data load. See more below. > > Additionally as I mentioned before, we see that from "pg_stat_database" > from the column "xact_commit" , it's almost matching with the sum of > "tup_inserted", "tup_updated", "tup_deleted" column. And also we > verified in pg_stats_statements the  "calls" column is same as the > "rows" column for the INSERT queries, so it means also we are inserting > exactly same number of rows as the number of DB calls, so doesn't it > suggest that we are doing row by row operations/dmls. > > Also after seeing above and asking application team to do the batch > commit ,we are still seeing the similar figures from pg_stat_database > and pg_stat_statements, so does it mean that we are looking into wrong > stats? or the application code change has not been done accurately? and > we see even when no inserts are running from the application side, we do > see "xact_commit" keep increasing along with "tup_fetched" , why so? > > Finally we see in postgres here, even if we just write a DML statement > it does commit that by default, until we explicitly put it in a > "begin... end" block. Can that be the difference between how a "commit" > gets handled in postgres vs other databases? 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. > > -- Adrian Klaver adrian.klaver@aklaver.com