I'm using postgres replication. I have one master and 2 slaves.
I have table first
with 1 500 000 rows. If I perform select count(*) from first
on master, it takes less than a second, but on both slaves it takes more than 500 seconds! Sometimes it's executing forever! It's ridiculous!
Query plan on master
Aggregate (cost=246018.54..246018.55 rows=1 width=0)
-> Seq Scan on news_event (cost=0.00..242254.63 rows=1505563 width=0)
On slave I can't get query plan - query execution works more than 30 minutes, I stop it.
Also, I have table second
with 6 500 000 rows, and count for this table works equally fast on master and both slaves.
Problem appeared after adding new column to first
table. About 24 hours before I added nullable column, and after that manually inserted default values to all rows. After that slave works extremely slow. All data on slaves is up to date.
I runned vacuum and analyze - nothing changed.