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

Would like to setup Postgresql 8.3 and above on Windows to automatically execute a series of SQL statements after the server has started.

Can't seem to find any information. Any ideas ?

share|improve this question

migrated from Jan 18 '12 at 21:43

This question came from our site for professional and enthusiast programmers.

It might not be possible. (Which role would it use to run the statements?) What do you want to run on the startup? – jkj Jan 19 '12 at 9:40
I would like to execute a few queries to pull some of the table data into the cache to improve the first use performance of our application. – glose Jan 20 '12 at 23:39

You can do this by creating another service that depends on Postgres & launches something that runs these queries, but in reality there's no point: Postgres will pull data into its cache (and the OS disk cache) on the first query it runs.
The Postgres cache will be voided any time Postgres needs that memory for something else (a big join). The OS disk cache will be voided any time the system needs that memory (big application, someone else pulling data off disk, etc.)

Bottom line: You might improve first-use performance if someone hits your application right after startup, otherwise these caches will start naturally emptying out and your optimization will drain away with them.

share|improve this answer

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.