Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TtNho-0002l5-L9 for pgsql-performance@arkaria.postgresql.org; Thu, 10 Jan 2013 19:22:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TtNhn-0007ni-Of for pgsql-performance@arkaria.postgresql.org; Thu, 10 Jan 2013 19:22:23 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TtNhm-0007nS-Lk for pgsql-performance@postgresql.org; Thu, 10 Jan 2013 19:22:22 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TtNhj-0005k4-Hs for pgsql-performance@postgresql.org; Thu, 10 Jan 2013 19:22:22 +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 25FA8283A9; Thu, 10 Jan 2013 11:22:16 -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 20FDBB05D6; Thu, 10 Jan 2013 11:22:16 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id C044F1219CB; Thu, 10 Jan 2013 11:24:17 -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 hRiOjM-bT9U3; Thu, 10 Jan 2013 11:24:17 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id 923061219D7; Thu, 10 Jan 2013 11:24:17 -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 7HQ1wk8jq2C7; Thu, 10 Jan 2013 11:24:17 -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 9A9EB1219CB; Thu, 10 Jan 2013 11:24:16 -0800 (PST) Message-ID: <50EF14F1.5070901@vmware.com> Date: Thu, 10 Jan 2013 21:22:25 +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> 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:11, Matheus de Oliveira wrote: > On Thu, Jan 10, 2013 at 4:54 PM, Heikki Linnakangas> wrote: > >> 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. > > Yeah. I thought about that, but the problem was that I assumed the INSERTs > came with random date, so in the worst scenario I would have to keep the > plans of all of the child partitions. Am I wrong? > > But thinking better, even with hundreds of partitions, it wouldn't use to > much memory/resource, would it? Right, a few hundred saved plans would probably still be ok. And if that ever becomes a problem, you could keep the plans in a LRU list and only keep the last 100 plans or so. - Heikki -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance