Analyze too slow after postgres upgrade I'm working on a testing server to upgrade a large database,  700GB with around 20000 tables.

The upgrade was fast enough using the --link option, but the analyze only script takes 8 hours, which is more downtime than I can justify. (9.3 to 9.4)

Is there anyway to speed up the analysis, or just run it in the background on the live production database after the upgrade?

What performance impact might this have?
8 hours to analyze 700GB seems like a really long time.  So, what makes it so slow?  Do you have expression indexes which use slow user-defined-functions?  That will certainly slow things down.  Do you have a very high setting for default_statistics_target?  Do you have a massively under-provisioned disk subsystem?

Are you using analyze-in-stages or just analyze-only?  

Are you doing it in parallel with -j option?  Probably not if you are only upgrading to 9.4 (which is itself a mistake--if the upgrade is traumatic for you, why not leap several versions at once so you don't need to do it as often?)

As for running it in the background, often a database can get by with no statistics or crude statistics for ordinary operations, and only needs detailed statistics for reporting or analytics such as weekly, end-of-month, or end-of-year reports.  So then you can get away with opening the database for ordinary use before the analyze is done. (Or if you do analyze-in-stages, open it after the first stage is complete).  On the other hand, some databases need good statistics right from the beginning because otherwise even routine queries will use such horrible plans that they essentially never finish, and will hog up so much CPU and disk resources that they slow down the vacuumdb script.

There is no way to know which case you will fall into without an intimate knowledge of the particulars of your database.  If you have a sampling of some typical and/or critical queries from your production system, you can replay them against a test server with no statistics and see what happens.