X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 7232B11F8CDF for ; Mon, 3 Apr 2006 06:42:29 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64099-02 for ; Mon, 3 Apr 2006 06:42:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) by postgresql.org (Postfix) with ESMTP id 70F6911F8CDD for ; Mon, 3 Apr 2006 06:42:25 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by pjetlic.mobart.hr (Postfix) with ESMTP id C020317ABF for ; Mon, 3 Apr 2006 11:42:23 +0200 (CEST) Received: from pjetlic.mobart.hr ([127.0.0.1]) by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 21431-04-2 for ; Mon, 3 Apr 2006 11:42:23 +0200 (CEST) Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by pjetlic.mobart.hr (Postfix) with ESMTP id A86A617ABA for ; Mon, 3 Apr 2006 11:42:23 +0200 (CEST) Subject: Measuring the execution time of functions within functions... From: Mario Splivalo Reply-To: mario.splivalo@mobart.hr To: pgsql-performance@postgresql.org Content-Type: text/plain Organization: Mob-Art Date: Mon, 03 Apr 2006 11:42:19 +0200 Message-Id: <1144057339.20123.18.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by OpenSource AV+AS Mail Server X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.136 required=5 tests=[AWL=0.136] X-Spam-Score: 0.136 X-Spam-Level: X-Archive-Number: 200604/21 X-Sequence-Number: 18105 I have asked this before, but haven't noticed any response, so if there were any, I appologize for asking this again... I have a function that is called by middle-tier (java trough JDBC), and in postgres log I can see only the execution time of that function. I have no idea how long are functions insde taking time to execute. Since the function is written in plpgsql I tried to calculate the durations by using now() function, but realized that within the transaction now() always retunrs the same value. The good thing is that those RAISE NOTICE calls from within my function are logged as they're encountered, so, with carefully placed RAISE NOTICE calls I could see how much time are the -inside- functions taking. For instance: CREATE FUNCTION test_outer() RETURNS void AS $$BODY$$BEGIN RAISE NOTICE 'We start here' PERFORM SELECT someInternalFunction1(); RAISE NOTICE 'InternalFunction1 is done now.'; PERFORM SELECT someInternalFunction2(); RAISE NOTICE 'InternalFunction2 is done now.'; -- ... more code here END$$BODY$$ LANGUAGE 'plpgsql' Is there any other, maybe more convinient way to measure the 'inside' function performance? I also have a problem if the outer function is written in SQL, like this, for instance: CREATE FUNCTION getSomeData(param1, param2, param3) RETURN SETOF someType AS $$BODY$$SELECT * FROM someTable JOIN someOtherFunction($1, $2, $3) ON someTable.col = someOtherFunction.col WHERE someCondition $$BODY$$ LANGUAGE 'sql'. Thank you in advance, Mario -- Mario Splivalo Mob-Art mario.splivalo@mobart.hr "I can do it quick, I can do it cheap, I can do it well. Pick any two."