Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

When using CREATE DATABASE TEMPLATE in PostgreSQL, will the target database preserve the statistics from the source database?

share|improve this question

Yes, it's a straight file-level copy of the template database, so whatever was in there will be in the new database.

share|improve this answer
Hmm, I cloned a database that had a vacuum/autovacuum listed in pg_stat_user_tables for example, but the cloned database did not (using "create database new template old;"). It seems the statistics did not get copied, I wrong? – wojo Feb 22 '12 at 18:17
The pg_stat_* tables are not actually tables but views that access information in shared memory. So the information there is not affected by the copying of the template database. – Peter Eisentraut Feb 22 '12 at 21:15

I do not believe so -- You will get a copy of the tables/triggers/etc., but they will have new OIDs, and the statistics will need to be regenerated.

It's possible that the statistics will be populated for you (equivalent of doing an ANALYZE on the new DB) - I haven't investigated that though, and if it's not the case you can speed up the process by doing it manually.

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.