Six policies to improve MySQL query speed Xiaoxiang blog

Source: Internet
Author: User
Tags mysql query
Six policies improve MySQL query speed

1. The table design must be optimized, with the least redundant data and less connection queries. If the complex connection and subquery are used in practical applications, the design of the data table must be reconsidered.

2. Try to use char instead of varchar, because the Fixed Length of string is faster to use. as hard disk capacity increases today, it is worthwhile to sacrifice storage space and increase the query speed.

3. Simplify the permission to increase the query speed. If you want to perform a lot of permission verification before a query, the query speed will slow down. Try to use root logon in MySQL and the new user logon speed with permission control, as you can see, the root login will suddenly enter, while the normal user login will always be delayed.

4,
Table optimization. If a table has been used for a period of time, the data will become fragmented as the update and deletion operations occur, which will also increase the time it takes for the physical search in the table. You need to know
Yes. In the MySQL underlying design, the database will be mapped to a directory with a certain file structure, while the table will be mapped to a file. Therefore, disk fragments are very likely to occur. Fortunately, in MySQL,
We can fix the problem through the following statement:
Optimize table tablename
Or
Myisamchk-r tablename

5. Using indexes, you can use indexes where you need to increase the query speed to simplify indexes and avoid creating indexes that are not used for queries. You can run the explain command to analyze and decide.

6. Use the default value to use the default value of the column as much as possible, and insert data only when the default value is different. This reduces the time spent executing the insert statement.

Reprinted: http://www.cnblogs.com/markor/archive/2007/05/12/744031.html

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.