Re: [PERFORM] Partition insert trigger using C language
2013/2/13 Matheus de Oliveira matioli.math...@gmail.com Hi Ali, That is probably because you did not passed a parameter when defined the trigger. You can follow the model at [1]. When creating the trigger, you have to use a string parameter with the name of the field with the date value used for the partition. Let me know if you find any other problem. [1] https://github.com/matheusoliveira/pg_partitioning_tests/blob/master/test/spi/schema.sql Regards, -- Matheus de Oliveira Analista de Banco de Dados Dextra Sistemas - MPS.Br nível F! www.dextra.com.br/postgres Hi Matheus, Yes. You are right. Now it's OK. I thought that the trigger function cannont vehicle any arguments. I had mis-interpreted this phrase of the Documentationhttp://www.postgresql.org/docs/9.2/static/sql-createtrigger.html: *function_name** * *A user-supplied function that is declared as taking no arguments and returning type trigger, which is executed when the trigger fires.* Thanks and best regards Ali
Re: [PERFORM] Partition insert trigger using C language
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.math...@gmail.com On Fri, Jan 11, 2013 at 8:19 AM, Heikki Linnakangas hlinnakan...@vmware.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 -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
Re: [PERFORM] Performance on Bulk Insert to Partitioned Table
2012/12/27 Charles Gomes charle...@outlook.com So far that's what I got http://www.widesol.com/~charles/pgsql/partition.c I had some issues as He uses HeapTuples and on 9.2 I see a Slot. Hi Charles, I copied your C code partition.c and am trying to test it. For compiling you suggest : ... gcc -I ./ -fpic -c trigger.c ... Where comes the file *trigger.c* from ? Is that the one you find in the source directory ./src/backend/commands/? Thanks a lot Best regards Ali
Re: [PERFORM] Performance on Bulk Insert to Partitioned Table
Ali, You can save the source as partition.c and use: gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fpic -DREFINT_VERBOSE -I. -I. -I/usr/pgsql-9.2/include/server/ -D_GNU_SOURCE -c -o partition.o partition.c gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fpic -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags -L/usr/pgsql-9.2/lib -lpgport -shared -o /usr/pgsql-9.2/lib/partition.so To Compile you must have postgresql-devel packages. I've added everything to github: https://github.com/charlesrg/pgsql_partition/blob/master/partition.c For more info check http://www.charlesrg.com/linux/71-postgresql-partitioning-the-database-the-fastest-way Thanks Charles, Now the compilation is OK. I'll test and feed back more information if any. best regards Ali