How to speed up queries

Source: Internet
Author: User
1. upgrade hardware 2. Create indexes based on query conditions, optimize indexes, optimize access methods, and limit the data volume of result sets. 3. Expand Server Memory 4. Increase server CPU count 5. Do not set Automatic database growth for large databases, it will reduce the server performance. 6. Use the WHERE clause in the query SELECT statement to limit the number of returned rows to avoid table scanning. If unnecessary data is returned, the server's I/O resources are wasted, this increases the burden on the network and reduces performance. If the table is large, the table is locked during the table scan and other connections are prohibited from accessing the table. The consequence is serious. 7. Do not return unwanted rows or columns during query. Use select Top 100/10 percent to limit the number of rows returned by the user or set rowcount to limit the number of rows to be operated. medium, place the most frequently occurring values at the beginning and the least frequently occurring values at the end, reducing the number of judgments by 10. Generally, redundant rows can be removed before the Group by having clause, so try not to use them to remove rows. Their execution sequence should be optimal as follows: Select WHERE clause Selects all appropriate rows, group by is used to group statistical rows, and having clause is used to remove redundant groups. In this way, the consumption of group by having is small, and queries are fast. Grouping and having large data rows consumes a lot of resources. If the purpose of group by is not to include computation, but to group, use distinct for faster 11. Update multiple records at a time. The score is updated multiple times. Each time, the record is updated fast, that is, the batch processing is good.

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.