Re: Partition insert trigger using C language - Mailing list pgsql-performance

From Heikki Linnakangas
Subject Re: Partition insert trigger using C language
Date
Msg-id 50EF14F1.5070901@vmware.com
Whole thread Raw
In response to Re: Partition insert trigger using C language  (Matheus de Oliveira <matioli.matheus@gmail.com>)
Responses Re: Partition insert trigger using C language
List pgsql-performance
On 10.01.2013 21:11, Matheus de Oliveira wrote:
> On Thu, Jan 10, 2013 at 4:54 PM, Heikki Linnakangas<hlinnakangas@vmware.com
>> 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


pgsql-performance by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Partition insert trigger using C language
Next
From: Matheus de Oliveira
Date:
Subject: Re: Partition insert trigger using C language