Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TtbiL-00015m-W2 for pgsql-performance@arkaria.postgresql.org; Fri, 11 Jan 2013 10:19:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TtbiK-0001pJ-Vy for pgsql-performance@arkaria.postgresql.org; Fri, 11 Jan 2013 10:19:53 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TtbiJ-0001pD-S2 for pgsql-performance@postgresql.org; Fri, 11 Jan 2013 10:19:52 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TtbiE-0000x5-US for pgsql-performance@postgresql.org; Fri, 11 Jan 2013 10:19:50 +0000 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id C5EB328A0E; Fri, 11 Jan 2013 02:19:45 -0800 (PST) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id BBDBF18547; Fri, 11 Jan 2013 02:19:45 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id 7BBD3121991; Fri, 11 Jan 2013 02:21:48 -0800 (PST) X-Virus-Scanned: amavisd-new at zcs-prod-ext-mta-1.vmware.com Received: from zcs-prod-ext-mta-1.vmware.com ([127.0.0.1]) by localhost (zcs-prod-ext-mta-1.vmware.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IHAryeC8q3TH; Fri, 11 Jan 2013 02:21:48 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id 4EFBC12199A; Fri, 11 Jan 2013 02:21:48 -0800 (PST) X-Virus-Scanned: amavisd-new at zcs-prod-ext-mta-1.vmware.com Received: from zcs-prod-ext-mta-1.vmware.com ([127.0.0.1]) by localhost (zcs-prod-ext-mta-1.vmware.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id MAraVgzPavVv; Fri, 11 Jan 2013 02:21:48 -0800 (PST) Received: from [192.168.1.90] (unknown [10.113.62.14]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTPSA id 5B6EB121991; Fri, 11 Jan 2013 02:21:47 -0800 (PST) Message-ID: <50EFE74B.9040007@vmware.com> Date: Fri, 11 Jan 2013 12:19:55 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121122 Icedove/10.0.11 MIME-Version: 1.0 To: Matheus de Oliveira CC: pgsql-performance , Charles Gomes Subject: Re: Partition insert trigger using C language References: <50EF0E81.1010808@vmware.com> <50EF14F1.5070901@vmware.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -6.9 (------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 10.01.2013 21:48, Matheus de Oliveira wrote: > I have made a small modification to keep the plans, and it got from > 33957.768ms to 43782.376ms. If I'm reading results.txt correctly, the avg runtimes are: C and SPI_execute_with_args: 58567.708 ms C and SPI_(prepare/keepplan/execute_plan): 43782.376 ms C and heap_insert: 33957.768 ms So switching to prepared plans helped quite a lot, but it's still slower than direct heap_inserts. One thing that caught my eye: > CREATE OR REPLACE FUNCTION partition_insert_trigger_spi() > RETURNS trigger > LANGUAGE C > VOLATILE STRICT > AS 'partition_insert_trigger_spi','partition_insert_trigger_spi' > SET DateStyle TO 'ISO'; Calling a function with SET options has a fair amount of overhead, to set/restore the GUC on every invocation. That should be avoided in a performance critical function like this. - Heikki -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance