/ postgresql

vacuum analyze new big table

I have a big table(compared to others table), yesterday I rebuilt it with some new columns, because I added an id as primary key, so I want this column on the first place of table, so I created a new table with new columns and old columns, populated data from old table.

After rebuilding this big table, some queries are slower than before, if I add some odd or unused ordering condition, that queries are fast as before. I searched that, someone on StackOverflow mentioned the statistics data used for query planing could be outdated.

So I run vacuum analyze TABLE_NAME, it works for me!