pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
execution time for first INSERT
2+ messages / 2 participants
[nested] [flat]

* execution time for first INSERT
@ 2011-07-08 11:23  Sergio Mayoral <mayoralstuttgart@yahoo.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Sergio Mayoral @ 2011-07-08 11:23 UTC (permalink / raw)
  To: pgsql-performance

Hi,

i am using libpq library and postgresql 8.4 for my linux application running on ARM with 256 MB. I am just doing:

PQconnectdb();
PQexec(INSERT INTO table1 ....); (0.009661 sec.)
PQexec(INSERT INTO table1 ....); (0.004208 sec.)

PQexec(INSERT INTO table2 ....); (0.007352 sec.)
PQexec(INSERT INTO table2 ....); (0.002533 sec.)
PQexec(INSERT INTO table2 ....); (0.002281 sec.)
PQexec(INSERT INTO table2 ....); (0.002244 sec.)

PQexec(INSERT INTO table3 ....); (0.006903 sec.)
PQexec(INSERT INTO table3 ....); (0.002903 sec.)
PQfinnish();

I check the time for each PQexec with gettimeofday function and I always see that the first INSERT for each table needs longer than the next ones.

this must be something with the parser stage and since i am doing every time the same queries, I would like to know if there is a way to cache these queries in order to speed up the first INSERT.

Thanks in advance,

sma



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: execution time for first INSERT
@ 2011-07-09 00:40  Jeff Davis <pgsql@j-davis.com>
  parent: Sergio Mayoral <mayoralstuttgart@yahoo.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Jeff Davis @ 2011-07-09 00:40 UTC (permalink / raw)
  To: Sergio Mayoral <mayoralstuttgart@yahoo.com>; +Cc: pgsql-performance

On Fri, 2011-07-08 at 04:23 -0700, Sergio Mayoral wrote:
> this must be something with the parser stage and since i am doing
> every time the same queries, I would like to know if there is a way to
> cache these queries in order to speed up the first INSERT.

I doubt it's the parser.

Seeing as it's around a couple ms at minimum, it's probably some kind of
IO latency. You could see that by wrapping the statements in a big
transaction (BEGIN/END block) -- I bet the inserts go very quickly and
the final commit takes longer.

Regards,
	Jeff Davis




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2011-07-09 00:40 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-07-08 11:23 execution time for first INSERT Sergio Mayoral <mayoralstuttgart@yahoo.com>
2011-07-09 00:40 ` Jeff Davis <pgsql@j-davis.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox