How to use index in select statement?

前端 未结 8 613
误落风尘
误落风尘 2020-12-12 12:42

Lets say in the employee table, I have created an index(idx_name) on the emp_name column of the table.

Do I need to explicitly specify the index name in

相关标签:
8条回答
  • 2020-12-12 13:22

    The optimiser will judge if the use of your index will make your query run faster, and if it is, it will use the index.

    Depending on your RDBMS you can force the use of an index, although it is not recommended unless you know what you are doing.

    In general you should index columns that you use in table join's and where statements

    0 讨论(0)
  • 2020-12-12 13:23

    By using the column that the index is applied to within your conditions, it will be included automatically. You do not have to use it, but it will speed up queries when it is used.

    SELECT * FROM TABLE WHERE attribute = 'value'
    

    Will use the appropriate index.

    0 讨论(0)
提交回复
热议问题