Re: dynamic SQL - possible performance regression in 9.2

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: dynamic SQL - possible performance regression in 9.2
Дата
Msg-id 3012.1357084083@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: dynamic SQL - possible performance regression in 9.2  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: dynamic SQL - possible performance regression in 9.2  (Peter Eisentraut <peter_e@gmx.net>)
Re: dynamic SQL - possible performance regression in 9.2  ("Dong Ye" <yed@vmware.com>)
Список pgsql-hackers
I wrote:
> I'm inclined to think that Heikki's patch doesn't go far enough, if we
> want to optimize behavior in this case.  What we really want to happen
> is that parsing, planning, and execution all happen in the caller's
> memory context, with no copying of parse or plan trees at all - and we
> could do without overhead such as dependency extraction and invalidation
> checking, too.  This would make SPI_execute a lot more comparable to the
> behavior of exec_simple_query().

Here's a draft patch for that.  My initial hack at it had a
disadvantage, which was that because no invalidation checking happened,
a SPI_execute query string containing a DDL command (such as ALTER TABLE)
followed by a command affected by the DDL would fail to reparse/replan
the second command properly.  (I suspect that Heikki's version had a
related defect, but haven't looked closely.)  Now that's not a huge deal
IMO, because in many common cases parse analysis of the second command
would fail anyway.  For instance, this has never worked in any PG
release:

do $$ begin execute 'create table foo(f1 int); insert into foo values(1);'; end $$;

However it troubled me that there might be some regression there, and
after a bit of reflection I decided the right fix would be to rearrange
the code in spi.c so that parse analysis of later parsetrees follows
execution of earlier ones.  This makes the behavior of SPI_execute()
even more like that of exec_simple_query(), and shouldn't cost anything
noticeable given the other changes here.

I'm not entirely sure about performance of this fix, though.  I got
numbers varying between roughly-on-par with 9.1 and 10% slower than 9.1
for Pavel's example, depending on seemingly not-performance-related
rearrangements of the code in spi.c.  I think this must be chance
effects of cache line alignment, but it would be good to hear what other
people get, both on Pavel's example and the other ones alluded to.
In any case this seems better than unmodified HEAD, which was 40% slower
than 9.1 for me.

            regards, tom lane


Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Noah Misch
Дата:
Сообщение: Re: default SSL compression (was: libpq compression)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: default SSL compression (was: libpq compression)