MySQL Performance Optimization Tips help your database _ MySQL
Source: Internet
Author: User
MySQL Performance Optimization Tips help your database bitsCN.com you have completed your brand new applications, everything works like a charm. To use your network. Everyone is happy.
Then, suddenly, an explosive user killed your MySQL server and your website was closed. What's wrong? How can you stop it?
The following are some tips for MySQL performance optimization, which will help you and your database.
Focus on In the early stages of development, you should know the expected number of users of your application. If you want many users, you should think about it. from the very beginning, we plan to replicate, scale, and performance.
However, if you optimize your SQL code, architecture, and indexing policies, you may not need the big environment. You must always think twice about performance and scalability.
Be sure to use EXPLAIN The EXPLAIN statement can be used as a way to obtain information. the alias for how MySQL executes the SELECT statement is DESCRIBE.
When the previous keyword explain select statement is used, the query execution plan of MySQL display information is optimized. That is to say, MySQL describes how it processes the SELECT statement, including the order in which the table is added. You can use the EXPLAIN extension to provide additional information.
Select the correct data type It is usually stored on disks (except for some databases and memory databases, it is stored in memory ). This means that, in order to obtain information for your database, it must read the information from the disk and convert it into a result set. you can use it. Disk I/O is extremely slow, especially when comparing other forms of data storage.
When your database grows, it takes a long time to start reading. Poorly designed databases handle this problem by allocating more space than the disks they actually need. This means that the disk occupied by the database is inefficient.
Selecting the correct data type helps ensure that the data we store is as small as possible. Therefore, we only select the data type we need.
Use persistent connection The reason for using permanent connections is that reducing the number of connections is quite expensive, even if they are faster with MySQL and most other databases.
There are some arguments about this topic. on the network, mysqli extension has disabled the persistent connection function, so I will write
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.