Database Query Tuning

Source: Internet
Author: User

1. SELECT clause

In sufficient cases, you can select only columns with indexes that are very fast

If unnecessary, selecting only the columns you want to view will increase your speed.

2. FROM clause

When you use join, you can directly join the table, and if the join subquery, the temporary table generated by the subquery is not indexed, so it can cause slow speed, and the direct join table can increase the speed.

Use different joins depending on the situation to increase the speed of queries and statistics

3. WHERE clause

Conditions in the WHERE clause:

Add an index of type btree if you need to sort, whether unique or not

If it is a unique value and does not require sorting, add a unique hash index

If it is not a unique value and does not require sorting, and if there are not many duplicate values, you can add a hash index

4. ORDER BY clause

By conditions it is best to add Btree index

  

Database Query Tuning

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.