I am creating a rails 3 app on Heroku and it’s using postgres as the database. In my rails migration I added indexes on all the ID columns. Was this a mistake? I’m starting to wonder if postgres has indexes by default on the ID columns.
If it was a mistake, how do I fix it? If I simply write a rails migration to remove the indexes from the ID columns will that fix everything?
According to postgresql’s documentation:
Hovewer, this does not prevent you from creating another index on the same columns. It might make sense if you use some different indexing policy (e.g. GiST index). But, if you are not sure about it, 99.9% that you have just created identical index.
Actually, this will not affect application functionality at all. The only thing to be concerned is that indexes are rebuilt on update operations, so it might pose some performance related issues. So, as manual suggests removing seldom-used indexes (last sentence), you’d better remove those indexes from db.
I’m not quite familiar with RoR migrations, but I think wriing a migration that remove those indexes is sufficient.