This script will generate minimal optimizer statistics rapidly so your system is usable, and then gather statistics twice more with increasing accuracy. When it is done, your system will have the default level of optimizer statistics. If you have used ALTER TABLE to modify the statistics target for any tables, you might want to remove them and restore them after running this script because they will delay fast statistics generation. If you would like default statistics as quickly as possible, cancel this script and run: vacuumdb --all --analyze-only Generating minimal optimizer statistics (1 target) -------------------------------------------------- vacuumdb: vacuuming database "postgres" vacuumdb: vacuuming database "template1" vacuumdb: vacuuming database "test" The server is now available with minimal optimizer statistics. Query performance will be optimal once this script completes. Generating medium optimizer statistics (10 targets) --------------------------------------------------- vacuumdb: vacuuming database "postgres" vacuumdb: vacuuming database "template1" vacuumdb: vacuuming database "test" Generating default (full) optimizer statistics (100 targets?) ------------------------------------------------------------- vacuumdb: vacuuming database "postgres" vacuumdb: vacuuming database "template1" vacuumdb: vacuuming database "test" Done