c-function variants running time
От | Armando |
---|---|
Тема | c-function variants running time |
Дата | |
Msg-id | 20120504164152.GB4240@eracle.unibz.it обсуждение исходный текст |
Ответы |
Re: c-function variants running time
|
Список | pgsql-hackers |
Hi everybody. First of all I have to thank you for your wonderful job! PostgreSQL rocks! I am writing you because I am interested in understanding some specifics related to PostgreSQL internals. More precisely, I am investigating the running time of the different function implementation approaches, which is part of my BSc thesis. Here is the thing: I have implemented as a proof of concept three functions, which are a) text[] arraypoc(text, int); this returns an array of the form 'text,int' where the text is the copy of the text passed as parameter and int is a simple counter. The number of tuples is specified by the integer parameter. I have estimated the running time in this manner: SELECT * FROM unnest(arraypoc('abcdefghilmnopqrstuvz',1000000)); The estimated running time is after 10 executions is: (791.571 + 797.163 + 677.331 + 686.674 + 686.691 + 686.438 + 797.910 + 795.955 + 793.459 + 794.110)/10 = 750.7302 b) TABLE(text,int) srfpoc(text, int); is similar as the previous one but this is a set returning function, which returns a table of a similar shape as in the previous case. Instead of a string, I return a text and an integer. Again text is just the copy of the parameter and int is a counter. I have estimated the running time in this manner: SELECT * FROM srfpoc('abcdefghilmnopqrstuvz',1000000); The estimated running time is after 10 executions is: (665.016 + 778.100 + 640.605 + 787.102 + 785.501 + 791.307 + 784.780 + 793.222 + 794.624 + 790.357)/10 = 761.0614 c) TABLE(text,int) srfmatpoc(text, int); this does the same as the previous one, but in this case I wrote a SRF_Materialized using the SPI interface. I have estimated the running time in this manner: SELECT * FROM srfmatpoc('abcdefghilmnopqrstuvz',1000000); The estimated running time is after 10 executions is: (747.095 + 703.894 + 762.310 + 763.299 + 764.582 + 760.991 + 763.427 + 764.033 + 731.292 + 770.895)/10 = 753.1818 I have executed all the tests on the same server. The functions are compiled using the -O3 compilation parameter. I am using PostgreSQL 9.1.3. I would have expected the version a) to be slower than b) and c) but it turns out that it is actually the fastest (the difference is not so big anyway). What am I doing wrong? What can I do to improve the functions? Have I misunderstood something? Attached you find the code of all three functions. Thanks a lot! Armando
Вложения
В списке pgsql-hackers по дате отправления: