Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 3DBBF650634 for ; Mon, 14 Jul 2008 06:33:53 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 79443-10 for ; Mon, 14 Jul 2008 06:33:45 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.156]) by postgresql.org (Postfix) with ESMTP id D08C5650630 for ; Mon, 14 Jul 2008 06:33:48 -0300 (ADT) Received: by fg-out-1718.google.com with SMTP id 16so2521638fgg.23 for ; Mon, 14 Jul 2008 02:33:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=38o994+fG+R4DcmTKLLlJoYME8KqvtV7WIreiFM1oHM=; b=AXEIF7jqFEGXGWCEvYoEmBByN4ofq1hOKGK9e4a2+WEN4sFrif1rQvTUsFCSNguOoa kxb25Oy569EWKXp2xyDXVUnvDekBC5mQMn9s3ZyblQDzHgD3OlN4iTRX9FKzdcUgNOPy LaehOUo1Lgp4/BS5mXzsdN0vZgvo34Ameo5cw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=Okz6IH/gqvuhbK8dKoWGp3g3ankha5uzZXd5BBRrNP2jxQPwaqo6tNhE6pBtXgrUyw 9Bi3svMWzOzj1p20Lq4Rg38lDYZzHtPzktjFqjpWb8wKJyNzQn+PB91SdIwcf2Nlx7xQ Xg6ZkDR2dZrd2as9Yn8cqGYKkUTMiIwDFzRsk= Received: by 10.86.92.7 with SMTP id p7mr13988855fgb.72.1216028026955; Mon, 14 Jul 2008 02:33:46 -0700 (PDT) Received: by 10.86.99.19 with HTTP; Mon, 14 Jul 2008 02:33:46 -0700 (PDT) Message-ID: <162867790807140233y56d53436pf194f6e38228052e@mail.gmail.com> Date: Mon, 14 Jul 2008 11:33:46 +0200 From: "Pavel Stehule" To: Praveen Subject: Re: Trigger is not firing immediately Cc: pgsql-performance@postgresql.org, andreas.kretschmer@schollglas.com In-Reply-To: <010901c8e581$a2b85370$274610ac@praveenkm> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <010901c8e581$a2b85370$274610ac@praveenkm> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200807/125 X-Sequence-Number: 30725 hello Are you sure, so you don't call trigger recursion? Regards Pavel Stehule 2008/7/14 Praveen : > > Hi all, > Please find the procedure and trigger which took more time when we try to > update value in table through Procedure. > > CREATE OR REPLACE FUNCTION procname1(args) > RETURNS void AS > $BODY$ > DECLARE > { > --- > Some code blocks > --- > } > BEGIN > > --> to here it is executing fastly after reaches this statement it's > taking time > > > update table1 set col1 = val1 where pk = val2 and col2 = val3; > > > -----> HERE table1 IS HAVING THE TRIGGER I GIVEN BELOW THE TRIGGER( > trigger1) > > > exception > WHEN OTHERS > THEN > raise notice '''EXCEPTION IN procname1 BLOCK 3 : %''',SQLERRM; > NULL; > END; $BODY$ > LANGUAGE 'plpgsql' VOLATILE; > ALTER FUNCTION procname1(args); > > > > > CREATE OR REPLACE FUNCTION trigger1() > RETURNS "trigger" AS > $BODY$ > BEGIN > > IF (TG_OP='UPDATE') THEN > IF( some condition ) > THEN > BEGIN > INSERT INTO table2(cols) > VALUES(values); > IF NOT FOUND THEN > NULL; > END IF; > EXCEPTION > WHEN OTHERS > THEN > NULL; > END; > END IF; > END IF; > RETURN NULL; > END; $BODY$ > LANGUAGE 'plpgsql' VOLATILE; > ALTER FUNCTION trigger1(); > > >> ----- Original Message ----- From: "A. Kretschmer" >> >> To: >> Sent: Monday, July 14, 2008 12:18 PM >> Subject: Re: [PERFORM] Trigger is not firing immediately >> >> >>> am Mon, dem 14.07.2008, um 12:04:49 +0530 mailte Praveen folgendes: >>>> >>>> Hi All, >>>> I am having a trigger in table, If I update the the table manually >>>> trigger >>>> is firing immediately(say 200ms per row), But if I update the table >>>> through >>>> procedure the trigger is taking time to fire(say 7 to 10 seconds per >>>> row). >>>> >>>> Please tell me what kind of changes can I make so that trigger fire >>>> immediately while updating the table through procedure ? >>> >>> Show us more details like source-code of the procedure, the trigger and >>> a demonstration. >>> >>> >>> Andreas >>> -- >>> Andreas Kretschmer >>> Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) >>> GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net >>> >>> -- >>> Sent via pgsql-performance mailing list >>> (pgsql-performance@postgresql.org) >>> To make changes to your subscription: >>> http://www.postgresql.org/mailpref/pgsql-performance >>> >> >> >> > > > > -- > Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-performance >