I’m curious how long will it take to put an index on the column in the db, that is not empty and has about 100,000 rows. I understand, it depends, but does it take a 0.1 second, 1 second or 10 minutes? Should I stop any actions from users during the indexing of a column in the db?
The reason I ask is I don’t know what columns should be indexed (to get an answer, I should measure it on practice, when the table grows), because the table is almost empty and the project is not uploaded.
Thank you.
1) Create a sqldump, load the data into another test database and try it out.
2) Yes, you should prevent user actions during any sort of DB maintenance. Even if the update is fast, something could go wrong and you should give yourself scope for the unexpected. It’s also a good practice to get into.
3) The best way to figure out what indices is needed doesn’t require much data:
a) Figure out the most frequently called and data intensive queries from a design point of view. Establish what they query on and the index requirements should be a logical next step.
b) Learn how to read query plans and look out for table scans, which you want to avoid.