Re: Partition insert trigger using C language

From: Ali Pouya <alipouya2(at)gmail(dot)com>
To: Matheus de Oliveira <matioli(dot)matheus(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(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-02-11 15:24:58
Message-ID: CAEEEPmyoDOm7q-iDsXWUEw4EjgV3xiDVoqLp+sQ1BfKrO-gmKw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi Matheus,
I try to use your partition_insert_trigger_spi.c code for testing SPI
partitionning.
But at execution time the *trigdata->tg_trigger->tgargs* pointer is null.
Do you know why ?
Thanks a lot
Best Reagrds
Ali Pouya

2013/1/11 Matheus de Oliveira <matioli(dot)matheus(at)gmail(dot)com>

>
> On Fri, Jan 11, 2013 at 8:19 AM, Heikki Linnakangas <
> hlinnakangas(at)vmware(dot)com> wrote:
>
>> 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.
>>
>>
> Humm... You are right, I misread what it before, sorry. The 33957.768ms
> was with heap_insert.
>
>
>
>> 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.
>>
>>
> I (stupidly) used SPI_getvalue [1] and expected it to always return as
> YYYY-MM-DD, but them I remembered it would do that only with DateStyle=ISO.
>
> But the truth is that I couldn't see any overhead, because the function
> was without that on my first tests, and after that I saw no difference on
> the tests. I think I should use SPI_getbinvalue instead, but I don't know
> how to parse the result to get year and month, any help on that?
>
> [1]
> https://github.com/matheusoliveira/pg_partitioning_tests/blob/master/src/spi/partition_insert_trigger_spi.c#L103
>
> Regards,
>
> --
> Matheus de Oliveira
> Analista de Banco de Dados
> Dextra Sistemas - MPS.Br nível F!
> www.dextra.com.br/postgres
>
>

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Johnny Tan 2013-02-11 22:10:47 Re: postgresql.conf recommendations
Previous Message Charles Gomes 2013-02-11 14:57:36 Re: postgresql.conf recommendations