Обсуждение: SELECT overhead in explicit transaction

Поиск
Список
Период
Сортировка

SELECT overhead in explicit transaction

От
"Blair Bethwaite"
Дата:
Hi all,

I'm wondering whether there would be any extra overhead (CPU, memory,
io, etc), above and beyond the implicit ACCESS SHARE, incurred by
putting a simple SELECT into a transaction block?

Cheers,
-Blair

--
In science one tries to tell people, in such a way
as to be understood by everyone, something that
no one ever knew before. But in poetry, it's the
exact opposite.
 - Paul Dirac

Re: SELECT overhead in explicit transaction

От
Tom Lane
Дата:
"Blair Bethwaite" <blair.bethwaite@infotech.monash.edu.au> writes:
> I'm wondering whether there would be any extra overhead (CPU, memory,
> io, etc), above and beyond the implicit ACCESS SHARE, incurred by
> putting a simple SELECT into a transaction block?

Every PG command is executed in a transaction, whether explicit or
implicit.  So there is not really any difference on the backend side
between "SELECT blah" and "BEGIN; SELECT blah; COMMIT".  However the
latter definitely can have some extra overhead.  At minimum the server
has got to parse two more statements, even though they don't do very
much when executed.  What is really likely to hurt, though, is if your
client-side code is such that you incur three round trips to the server
instead of just one ...

            regards, tom lane