SQL optimization suggestion Memorandum

Source: Internet
Author: User

SQL optimization suggestion Memorandum 1. SQL comments generally do not increase performance overhead, and can enhance readability 2. The transaction should be brief www.2cto.com 3. Avoid cursor operations because the cursor occupies a large amount of resources 4. Balance between IN and EXISTS 5. Avoid nested views and avoid it during single table search the overhead of view 6, DISTINCT, and order by pointing to multiple tables can be processed in the application. 7. Set the default value for each column as much as possible, and not null. Because columns containing NULL values cannot use indexes, even if you create an index. Queries that use is null and is not null do NOT use indexes 8. Massive queries avoid type conversion 9. Create indexes for columns associated with foreign keys 10. UNION and union all, the latter is more efficient. 11. insert into table VALUES (...) Performance is worse than insert into table (...) VALUES (...) 12. Notes when using order by any non-index item or Calculation Expression in order by will reduce query efficiency 13. Balance BETWEEN and IN...

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.