Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 85A27632432 for ; Wed, 26 May 2010 05:50:30 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 24561-02 for ; Wed, 26 May 2010 08:50:18 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from web110412.mail.gq1.yahoo.com (web110412.mail.gq1.yahoo.com [67.195.8.236]) by mail.postgresql.org (Postfix) with SMTP id ECFB96325EF for ; Wed, 26 May 2010 05:50:18 -0300 (ADT) Received: (qmail 83889 invoked by uid 60001); 26 May 2010 08:50:17 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1274863817; bh=i5AblbWjymbQHxdSAvd0NPn3Ormgl8fqMTRvRgNFYOI=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=Gs1hyFo136kZp7WiggD8qR/Skkux16V9S77DMM6Xbd4t97HwJWZktkRip+Ph1mfhXAxYY3+7rk/gCloh+RQ/jXwPqUpj06uXJSKwGmUovolzhqLHRCQqfY8g0sx2TItNxg18nSOkuDqkBTD9WchwaZ+3dolgoFH8yYIU/TbuPnI= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=ytJ8OxutUhjMK9Eq18QTmcp4KE36U/A8l7eW8FCot+2fWC/srx+L08YebkLYueFdl82Xbuf6Uc/VZQMs9oac0/8fmQUNGWMrYFnmMZaL34YIyZOKrD/UTz9QKetFVF68ag+DUStFA/JC7sXnuBw34c8rOtMr1oN8Qg+/X4rErHE=; Message-ID: <34816.46946.qm@web110412.mail.gq1.yahoo.com> X-YMail-OSG: mAV3ISgVM1lw0M.0MSMGA3hRUvwfXYh_Pm850vX_kFWE9JF t1D57Y3iovQrHA.CC3PLPalME_vvcqN.TPDHVf0kI1JPhrjqYVvq2KOdr9T0 q2wDSM3s9x3QzhStgMfi7qHcGdYbKq8hM16HB_v0drfGMuoVfK6YA2Lk7gZ4 i3Ud9iNtHxqONhy5kgMrUQeXI.kCsnYxl4LmvjYhfX6SQstog3dxHeHqjVji oTmK_bK_qDxxzs8VW.L.U2vOfeGLCHnd_eQPLhg.5Bjp3LaAyQt4fCfJhFm3 JE7kwWN1K8.rqzfKn5wDxhwRe8zd37xNgQM64T5tkd0iIGkZP0PXrmA-- Received: from [58.65.169.83] by web110412.mail.gq1.yahoo.com via HTTP; Wed, 26 May 2010 01:50:16 PDT X-Mailer: YahooMailRC/374.4 YahooMailWebService/0.8.103.269680 Date: Wed, 26 May 2010 01:50:16 -0700 (PDT) From: Altaf Malik Subject: Function with raise notice statements taking too long To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1073580680-1274863816=:46946" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.509 tagged_above=-10 required=5 tests=BAYES_05=-0.5, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/70 X-Sequence-Number: 20554 --0-1073580680-1274863816=:46946 Content-Type: text/plain; charset=us-ascii Hi, I have a plpgsql function with raise notice statements in a loop. When I call this function from JDBC, it takes almost 5 minutes to execute. However, if I invoke it through pgAdminIII, it gets executed in just 12 seconds. The code of the function is given below: CREATE OR REPLACE FUNCTION f1() RETURNS void AS $BODY$ declare i integer := 0; start_time timestamp; end_time timestamp; begin start_time := now(); LOOP exit when i = 100000; RAISE NOTICE 'Program is on the line number: %',i ; i := i + 1; END LOOP; end_time := now(); RAISE NOTICE 'Program start time: %', start_time; RAISE NOTICE 'Program End time: %', end_time; end; $BODY$ LANGUAGE 'plpgsql' I invoke it from pgAdminIII using: select f1() I used the following java program to execute it and it takes too long. Class.forName("org.postgresql.Driver"); Connection con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres","postgres","postgres"); System.out.println("Starting ..."); CallableStatement stmt = con.prepareCall("{call f1()}"); stmt.execute(); SQLWarning warn = stmt.getWarnings(); while (warn != null) { System.out.println(warn.getMessage()); warn = warn.getNextWarning(); } System.out.println("Done"); Any clue why JDBC is performing too slow? I am using: Databse: "PostgreSQL 8.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-10), 32-bit" Driver: 8.5devel Regards, Altaf Malik --0-1073580680-1274863816=:46946 Content-Type: text/html; charset=us-ascii
Hi,
 I have a plpgsql function with raise notice statements in a loop. When I call this function from JDBC, it takes almost 5 minutes to execute. However, if I invoke it through pgAdminIII, it gets executed in just 12 seconds. The code of the function is given below:

CREATE OR REPLACE FUNCTION f1() RETURNS void AS
$BODY$ declare
    i integer := 0;
    start_time timestamp;
    end_time timestamp;
 begin
    start_time := now();
    LOOP
        exit when i = 100000;
        RAISE NOTICE 'Program is on the line number: %',i ;
        i := i + 1;
   END LOOP;

    end_time := now();
   
    RAISE NOTICE 'Program start time: %', start_time;
    RAISE NOTICE 'Program End time: %', end_time;

 end; $BODY$
  LANGUAGE 'plpgsql'


I invoke it from pgAdminIII using: select f1()

I used the following java program to execute it and it takes too long.

  Class.forName("org.postgresql.Driver");
  Connection con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres","postgres","postgres");
  System.out.println("Starting ...");

   CallableStatement stmt = con.prepareCall("{call f1()}");
   stmt.execute();

        SQLWarning warn = stmt.getWarnings();
        while (warn != null) {
            System.out.println(warn.getMessage());
            warn = warn.getNextWarning();
        }
        System.out.println("Done");


Any clue why JDBC is performing too slow?

I am using:

Databse: "PostgreSQL 8.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-10), 32-bit"
Driver: 8.5devel

Regards,
Altaf Malik

--0-1073580680-1274863816=:46946--