Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

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

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

Your Answer

 
discard

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.