Reputation: 61
In MySQL you create your database with the neccesary indexes before using it, but since mongodb creates the database on inserting, i was wondering where i have to put my index creation?
In which part of the code? Once in an initalization part? After each insert? Before a query?
Thanks for the advice!
Ruben
Upvotes: 1
Views: 289
Reputation: 43884
In MySQL you create your database with the neccesary indexes before using it
So, how do you add new indexes to MySQL? I don't think that statement holds true. In fact I tend to make the database schema and application code up and then add indexes depending on how I query the data. You only know what indexes you need after using the database.
Same is true for MongoDB.
MongoDB indexes only need to be created once.
As to when to make them: the best time would probably be after you have completed your code development but before you deploy to public.
You can add it to your application code but normally I do index management separately since they work separately to the application in many cases, especially when you start getting into the more advanced features of MongoDB such as replication.
Upvotes: 1
Reputation: 197
why you do not use GUI to control the indexes and tables[collections] . I use Rockmongo.
use this url , copy it on a directory and use it as phpmyadmin
one of the abilities is indexes :)
Upvotes: 0