Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 4E14AB5DBC4 for ; Thu, 3 Nov 2011 19:42:28 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 60383-01 for ; Thu, 3 Nov 2011 22:42:16 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail-yw0-f46.google.com (mail-yw0-f46.google.com [209.85.213.46]) by mail.postgresql.org (Postfix) with ESMTP id 90FD6B5DC07 for ; Thu, 3 Nov 2011 19:42:16 -0300 (ADT) Received: by ywf7 with SMTP id 7so1827343ywf.19 for ; Thu, 03 Nov 2011 15:42:16 -0700 (PDT) Received: by 10.150.215.2 with SMTP id n2mr12380373ybg.12.1320360136041; Thu, 03 Nov 2011 15:42:16 -0700 (PDT) Received: from issac.consistentstate.com (173-164-51-9-colorado.hfc.comcastbusiness.net. [173.164.51.9]) by mx.google.com with ESMTPS id 8sm21247341anv.16.2011.11.03.15.42.14 (version=SSLv3 cipher=OTHER); Thu, 03 Nov 2011 15:42:15 -0700 (PDT) Message-ID: <4EB318C5.20504@consistentstate.com> Date: Thu, 03 Nov 2011 16:42:13 -0600 From: CS DBA User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110928 Fedora/3.1.15-1.fc14 Lightning/1.0b2 Thunderbird/3.1.15 MIME-Version: 1.0 CC: "pgsql-performance@postgresql.org" Subject: Re: function slower than the same code in an sql file References: <4EAA3597.3020202@consistentstate.com> <14399.1319778608@sss.pgh.pa.us> <4EAAB09C.9060202@consistentstate.com> <4EB2B3EF.60502@estrads.com.ar> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.879 tagged_above=-10 required=5 tests=BAYES_00=-1.9, MISSING_HEADERS=1.021 X-Spam-Level: X-Archive-Number: 201111/71 X-Sequence-Number: 45582 On 11/03/2011 09:40 AM, Robert Haas wrote: > On Thu, Nov 3, 2011 at 11:31 AM, Rodrigo Gonzalez > wrote: >> El 03/11/11 11:42, Robert Haas escribió: >> >> On Fri, Oct 28, 2011 at 9:39 AM, CS DBA wrote: >> >> No parameters, one of them looks like this: >> >> [ code snippet ] >> >> It's hard to believe this is the real code, because SELECT without >> INTO will bomb out inside a PL/pgsql function, won't it? >> >> But he's using CREATE TABLE xyz_view_m AS >> >> So it seems correct to me > Oh, right, I missed that. > > That seems pretty mysterious then. But is it possible the function is > getting called more times than it should? I notice that it's set up > as a trigger; is it FOR EACH ROW when it should be a statement-level > trigger or something like that? Maybe run EXPLAIN ANALYZE on the > query that's invoking the trigger to get some more detail on what's > going on? I'll give it a shot ... -- --------------------------------------------- Kevin Kempter - Constent State A PostgreSQL Professional Services Company www.consistentstate.com ---------------------------------------------