SQL efficiency improvements Some SQL authoring recommendations and efficient use of index _mssql
Source: Internet
Author: User
1. Date attribute column, do not slow down query speed because there is a minute difference
2. When querying using like comparisons, indexing is more efficient if the pattern starts with a specific string such as "abc%", and the index does not work if the pattern starts with a wildcard character such as "%xyz"
3. Or will cause a full table scan, and and in the role of equivalent
4. Use not as little as possible
5. The execution efficiency of EXISTS and in is the same
6. Use function charindex () and the preceding wildcard character% like execution efficiency
7. Union is not absolutely more efficient than the execution of or
8. Field extraction According to the "How much, how much" principle, avoid "SELECT *"
9. Count (*) is not slower than count (field)
Order BY clustered indexed columns most efficient
11. Multi-use "top" for data extraction, can improve efficiency
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.