Wednesday, August 21, 2013

Where to put index in a database

Hi All,
Index are used for faster searching. Just as in Books, index helps us to find a topic fast. Similarly we use index on a database table to make our query fast. Now the question is on which column we should put index. Answer is quite obvious from book example. We should put out index on the column which is used for searching. Suppose you have a employee table with  columns as employee_id,name,email,salary,address,last_updated etc. Now if you frequently query employee table as "select * from employee where name='x'" then you should be put index on column "name".

No comments:

Post a Comment