Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot execute ANALYZE during recovery

We have a insert only table for which we often get bad results due to query plan using nested loops instead of hash joins. To solve this we have to run ANALYZE manually (vacuum sometimes don't run on insret only tables, long story, not the point here). When I try to run analyze on replica machine, I get ERROR: cannot execute ANALYZE during recovery error. So this made me think that we maybe don't need to execute ANALYZE on replica.

My question is: are statistics propagated to replica when executing analyze on master node?

Question in link below is similar to this one, but it is asked in regards to vacuum. We are only using ANALYZE. https://serverfault.com/questions/212219/postgresql-9-does-vacuuming-a-table-on-the-primary-replicate-on-the-mirror

like image 881
Damir Ciganović-Janković Avatar asked May 13 '20 11:05

Damir Ciganović-Janković


1 Answers

Statistics are stored in table, and this table is replicated from primary server to replica. So you don't need and you cannot to run ANALYZE on replica (physical replication)

like image 116
Pavel Stehule Avatar answered Oct 19 '22 06:10

Pavel Stehule