Re: Partition insert trigger using C language

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Matheus de Oliveira <matioli(dot)matheus(at)gmail(dot)com>, pgsql-performance <pgsql-performance(at)postgresql(dot)org>, Charles Gomes <charlesrg(at)outlook(dot)com>
Subject: Re: Partition insert trigger using C language
Date: 2013-01-10 19:14:58
Message-ID: CAFj8pRCTPGcPk=U0mO5rFmFFU_TiwE_9e-HxTjhu64-4aQvaWw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

2013/1/10 Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>:
> 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.

This a problematic for partitioning, because you need too much plans -
and direct access is probably better - I am thinking.

On second hand, there is relative high possibility to get inconsistent
relations - broken indexes, if somebody don't write trigger well.

Maybe we can enhance copy to support partitioning better. Now I have a
prototype for fault tolerant copy and it can work nice together with
some partitioning support

Regards

Pavel

>
> - Heikki
>
>
> --
> Sent via pgsql-performance mailing list (pgsql-performance(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-performance

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Heikki Linnakangas 2013-01-10 19:22:25 Re: Partition insert trigger using C language
Previous Message Matheus de Oliveira 2013-01-10 19:11:48 Re: Partition insert trigger using C language