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 1rwpKl-004Q5p-0c for pgsql-general@arkaria.postgresql.org; Tue, 16 Apr 2024 20:23:15 +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 1rwpKj-006Irp-D8 for pgsql-general@arkaria.postgresql.org; Tue, 16 Apr 2024 20:23:13 +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 1rwpKi-006Irh-Hh for pgsql-general@lists.postgresql.org; Tue, 16 Apr 2024 20:23:13 +0000 Received: from wfhigh8-smtp.messagingengine.com ([64.147.123.159]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rwpKf-003BWs-NM for pgsql-general@lists.postgresql.org; Tue, 16 Apr 2024 20:23:11 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.west.internal (Postfix) with ESMTP id 52AED180013C; Tue, 16 Apr 2024 16:23:08 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 16 Apr 2024 16:23:08 -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=fm1; t=1713298987; x=1713385387; bh=9X4qYHE8PcgplJYon73ynLcH52J7eu0iuYzUeKKcpvE=; b= dos3TYIQnKi+I+7cbt4vF50n1D+wpcO3kzu+bGfB+YfVhSU+XXe9LK6cheF2C8Kr IpFbQ6GL+M7vAAl1S9cggDoZqd+XjsFoJW1YvCvCbgP0WJ1aptn/WUbuNgIiZVK+ 9mNBUp3Gj/8rNnNRu06eKrCnyJKrd74HY37ljX7Prlm22mkmuwSZqnaT3+nliYfJ yj5blV+x+DasC+1fw56ch7rFJQVuAr6ygHfilXfZ83GipjCZsGkYTyTudXmE6/0b nqHxTMpjyb0UteOlkMe2FpROZjOF7m5Q3sDThzG3abixfVTwSIJlNEK9ogqJbQES CPg0Lk5NgBO4hApTsJg/Ug== 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=fm2; t=1713298987; x= 1713385387; bh=9X4qYHE8PcgplJYon73ynLcH52J7eu0iuYzUeKKcpvE=; b=X Z6RmDSrMf4FudUeYJkIDVEDllOqV7Pk/s6W9pUpQ4B0mJerSgN0OL97yRjwEW2Kg MBoFOJStT5IPc2NarLr4M03zZULRVLIfwNw8cnysAmukQBx4LkSGFR1y7lR2EYje mmiCoIzyGO5z7uiCnJS+BrQj7qmG493nsVfHn68zONf0qpHcQZJ55w9/e1EyTh9i K4wL8hUjnMhL/yzJ2NzREToVJGMWTvhJtG+C+G8Gm1sT1mhpAdRYuGDDyQ7oenEY C2GMCO7pSYAYKJy7H/c5xguXXdQ+mAyigFJTEMR8r5ZlJFGTonTAjhcjStjSn/QB 2zbBrDRacQD+zroU3N8/g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudejiedgkeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhepfeegfeeiuedtgffgteeggfehkeejheetieeliefg teeikeejvdeiveeigfehvedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 16 Apr 2024 16:23:07 -0400 (EDT) Message-ID: <7480b130-7926-439e-b550-181cbfc12a35@aklaver.com> Date: Tue, 16 Apr 2024 13:23:06 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Question on trigger To: veem v Cc: pgsql-general References: <5a4a8556-bef0-4509-b8ce-98ccac24bd60@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 4/16/24 12:39, veem v wrote: > > > On Sat, 13 Apr 2024 at 21:44, Adrian Klaver > wrote: > > On 4/13/24 00:03, veem v wrote: > > Thank you Adrian. > > > > So it seems the heavy DML tables will see an impact if having > triggers > > (mainly for each row trigger) created on them. > > > > And also the bulk DML/array based insert (which inserts multiple > rows in > > one short or one batch) , in those cases it seems the trigger > will not > > make that happen as it will force it to make it happen row by > row, as > > the trigger is row based. Will test anyway though. > > You said you have triggers in the Oracle database and I assumed they > worked and where not a show stopping issue there. What makes you think > that would be different in Postgres? > > What type of triggers where there in Oracle, per row, per statement > or a > mix? > > > Actually we have row level triggers  in oracle which are running for > smaller volume DML and are making the direct path inserts to happen in > conventional row by row insert, in presence of trigger. So was wondering Not sure what the above means, you will need to provide a more detailed description. Though any DML you are doing on table that has any sort of constraint, index, trigger, foreign key, default values, etc is going to have more overhead then into an unencumbered table. FYI, some of the preceding are system triggers, for example foreign keys. > if it postgres we will be encountering a similar issue and batch inserts > may be converted back to row by row automatically. And here we are going > to process higher volume DMLS in postgresql database. > Hard to say with the information provided. Easiest way to find out is create a test setup and run the code. Though I guess, as I have not actually tried this, you could have a per row trigger and per statement trigger for the same action and disable the per row and enable the per statement trigger for batch operations. Then once the batch operation is done reverse the process. Again something to test to verify. -- Adrian Klaver adrian.klaver@aklaver.com