Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TtNHE-0002J2-Se for pgsql-performance@arkaria.postgresql.org; Thu, 10 Jan 2013 18:54:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TtNHD-0002Qa-VM for pgsql-performance@arkaria.postgresql.org; Thu, 10 Jan 2013 18:54:56 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TtNHD-0002QV-2O for pgsql-performance@postgresql.org; Thu, 10 Jan 2013 18:54:55 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TtNH7-0004Rv-8x for pgsql-performance@postgresql.org; Thu, 10 Jan 2013 18:54:54 +0000 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id BA0D22839E; Thu, 10 Jan 2013 10:54:47 -0800 (PST) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id B58CBB050F; Thu, 10 Jan 2013 10:54:47 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id 55E5A1219E2; Thu, 10 Jan 2013 10:56:49 -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 09gSoVtBb4oZ; Thu, 10 Jan 2013 10:56:49 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id 2CDF2121A1B; Thu, 10 Jan 2013 10:56:49 -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 zPdERfqTb25i; Thu, 10 Jan 2013 10:56:49 -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 2EB2E1219E2; Thu, 10 Jan 2013 10:56:47 -0800 (PST) Message-ID: <50EF0E81.1010808@vmware.com> Date: Thu, 10 Jan 2013 20:54:57 +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: 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 20:45, Matheus de Oliveira wrote: > Inspired by Charles' thread and the work of Emmanuel [1], I have made some > experiments trying to create a trigger to make partitioning using C > language. > > The first attempt was not good, I tried to use SPI [2] to create a query to > insert into the correct child table, but it took almost no improvement > compared with the PL/pgSQL code. The right way to do this with SPI is to prepare each insert-statement on first invocation (SPI_prepare + SPI_keepplan), and reuse the plan after that (SPI_execute_with_args). If you construct and plan the query on every invocation, it's not surprising that it's no different from PL/pgSQL performance. - Heikki -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance