I'm using some tables like pg_stat_user_tables
and to optimize pg_stat_user_indexes
our indexes and I found that this table it's different between the writer
and reader
.
Someone knows why this happens? And which table we can trust for tunning?
This is expected. Statistics that are 'usage' related are specific to the instance/server. Only stats like pg_stats which has things like ndistinct, most common values/frequencies, histogram, etc --- basically what is the "shape/size" of the data stored in tables (and functional indexes, and multi-variate statistics objects that get created) would be the same between primary & reader.