Re: Notes about Pl/PgSQL assignment performance
От | Pavel Stehule |
---|---|
Тема | Re: Notes about Pl/PgSQL assignment performance |
Дата | |
Msg-id | CAFj8pRAc4qHKCiZyKFZaYWhg3q0yV9cSZh4p1AZ_RA88ZknfQw@mail.gmail.com обсуждение исходный текст |
Ответ на | Notes about Pl/PgSQL assignment performance (Андрей Жиденков <pensnarik@gmail.com>) |
Ответы |
Re: Notes about Pl/PgSQL assignment performance
Re: Notes about Pl/PgSQL assignment performance |
Список | pgsql-hackers |
Hi
2017-12-19 12:28 GMT+01:00 Андрей Жиденков <pensnarik@gmail.com>:
Few day ago a faced a problem: Pl/PgSQL procedure works slower when running in parallel threads. I found the correlation between number of assignments in procedure code and performance. I decided to write the simple benchmark procedures and perform some test on PostgreSQL 9.6.5 database installed on the server with 20 CPU cores (2 Xeon E5-2690V2 CPUs).This benchmark showed me that a simple Pl/PgSQL procedure with a simple loop inside works slower when running even in 2 threads. There is a procedure:CREATE OR REPLACE FUNCTION benchmark_test() RETURNS VOID AS $$DECLAREv INTEGER; i INTEGER;BEGINfor i in 1..1000 loopv := 1;end loop;END;$$ LANGUAGE plpgsql;What is the point? I know, that Pl/PgSQL performs a SELECT query to calculate each value for assignment but I didn't expect that it produce side effects like this. If there is some buffer lock or anything else?
I am little bit lost when you are speaking about threads. Postgres doesn't use it.
your test is not correct - benchmark_test should be marked as immutable. What will be result?
Regards
Pavel
I've been written a post with charts and detailed explanation to display these side effects: http://telegra.ph/Notes-about-PlPgSQL- assignment-performance-12-19 Any help would be greatly appreciated.--
В списке pgsql-hackers по дате отправления: