Suppose Bob has earned 107 points, Mary 105 points and John also 105 points. These numbers could change and are not unique. Now I want to query and check the order, who is on top and who is on the bottom. Does that column that holds points need to be indexed ?
It depends on the database system used and the size (number of rows) of the table.
If the table is small enough and you're using MSSQL for example, a table scan will be used (the entire table will be read into memory) and an index will be relatively useless.
Generally speaking, yes - the field should be indexed if that is the column you'll be using to select or sort data.
As a very general rule, I consider indexing columns that appear in the WHERE or ORDER BY clauses of commonly executed queries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With