Discussion on index invalidation in SQL Server database

Source: Internet
Author: User

There are questions about indexing failures in the database, and there are related discussions on the web. However, they were discussed for the Oracle database. So when is the index in the SQL Server database

Will fail. Sum up, but I haven't been tested. Without testing there is no say, here for your own reference only.

First, the so-called invalidation. It's not really the index that was deleted. Instead, in these cases, the DBMS does not retrieve the index list. The execution speed is the same as the speed without this index.

But then another statement is executed. The same index can work correctly. So the invalidation of an index is for an SQL statement, not for the index itself. So under what circumstances,

Exactly what type of statement is executing when the index does not work. Summarized as follows:

1. When the index field is queried for a null query. That is, when the index field is judged to be null. The statement is either NULL or is not NULL.
For example, the SELECT * from temp where time is null does not retrieve the index table on the now field. That is, the index was invalidated when this statement was executed. and then

Row SELECT * from temp where time = ' 2010-06-01 ' This will retrieve the index table. The index works again.


2. When you make a like query on an indexed field. For example: SELECT * from temp where des like '% Wang '. Some examples on the web say that the like ' xx% ' index works. I haven't tried.

3. Determine if the index column is not equal to a value. '! = ' operator. For example: SELECT * FROM temp where amount! = 0.

4. Perform an operation on the indexed column. The operations here include +-*/and other operations. Also includes the use of functions. Like what:
SELECT * FROM temp where amount+count>10 the index does not work at this time.
SELECT * FROM temp where round (amount) >10 the index does not work at this time.
That is, if the Index field column is not judged directly, it is the index column that is processed by the operation or other function. indexes do not work.

Discussion on index invalidation in SQL Server database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.