Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use Aqua Data Studio in OS X to make queries in a PostgreSQL server, but the first query of the day runs too slow.

It not depends on the SQL, a simple SELECT current_timestamp will parse and execute in about 5 seconds, any subsequent query will take almost 30ms. If I close the app, reopen and try again this does not happen, only when restarting the machine.

If I use PgAdmin, it works fine from the first query. In Aqua it will be very clear that is not the execution time, but the parsing time that is causing this.

Now we have a continuous integration server, which runs a lot of tests at every commit, but fails at every first build of the day, and until we do a second commit (or do a forced build) it will be failed. This machine is a Linux one, and the build is a java app using JDBC, making me discard an OS issue and consider more a PostgreSQL + JDBC issue.

The primary server I am running on:

PostgreSQL 8.4.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (Debian 4.3.2-1.1) 4.3.2, 64-bit

But it happens on several servers and versions:

PostgreSQL 8.4.1 on x86_64-unknown-linux-gnu, compiled by GCC gcc (Debian 4.3.2-1.1) 4.3.2, 64-bit

PostgreSQL 9.1alpha3 on x86_64-unknown-linux-gnu, compiled by GCC gcc (Debian 4.3.2-1.1) 4.3.2, 64-bit

If I execute the first query on any server, any subsequent, on any server, will be ok.

Anyone has experienced this? How could I try to identify what is causing this?

share|improve this question

This looks a lot like your database will be paged out over night or after system start when other processes need a lot of memory.

I think it would make sense to either add more memory to the db server. Another option is to issue that above select current_timestamp from a script before the CI server runs the tests (e.g. in some pre-built phase) to have the DB being paged in. The script would call the psql command line utility to issue the select.

share|improve this answer
But in this case PgAdmin should have the same problem, which is not the case. In PgAdmin - that I don't know the way it connects to postgres - it works fine from the start. – Fernando M. Pinheiro Jul 19 '11 at 13:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.