On 2014-07-20 14:43:27 +0200, Fabien COELHO wrote:
> >a) Consider using the extended query protocol.
> >b) consider using unnamed prepared statements to reduce the number of
> > roundtrips
> >c) wonder why PREPARE/DEALLOCATE are so much more frequent than the
> > actualy query execution.
>
> (1) I'm not responsible for DBD::Pg allocating "random" names to prepared
> statements, even if the queries are the same, and that accumulate over time
> (weeks, possibly months).
>
> (2) pg_stat_statements is currently inconsistent anyway, as PREPARE is not
> counted (but the underlying query is on each EXECUTE), although its
> corresponding DEALLOCATE is counted, so I think that something is needed for
> consistency.
That's because PREPARE isn't executed as it's own statement, but done on
the protocol level (which will need noticeably fewer messages). There's
no builtin logic to ignore actual PREPARE statements. So I don't think
your consistency argument counts as much here.
Greetings,
Andres Freund
-- Andres Freund http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services