Basic understanding of mysql Storage Performance Optimization

Source: Internet
Author: User

I have learned about mysql database performance optimization and design over the past few days. Now I am going to make a summary of my own learning. In the future, I will continue to study in depth and make a summary:

1. Use Indexes
Each table can have a maximum of 16 indexes, including multi-column indexes and full-text indexes.
Create index index_name on users (username );
View indexes: show index from users;
It is a double-edged sword. If indexes are not created, the table function is used to find a balance point ,.


2. Use explain to analyze and query
Explain in the query
Explain select * from users;


3. Adjust the internal configuration of mysql


(1) Change the index buffer length (key_buffer );
We recommend that you set 25% of the system memory.


(2) Change the table length (read_buffer_size)
When the database frequently scans a table, mysql allocates a memory buffer. If you think the scan is too slow, you can adjust the size of the value.


(3) set the size of the opened table (table_cache)
This variable controls the maximum number of tables opened by mysql at any time, thereby controlling the server's ability to respond to input requests. He and max_connections


(4) set a time limit for slow query (long_query_time)
YSQL has a "Slow query log", which automatically records all queries that have not been completed within a specific time range. This log is useful for tracking inefficient or misperforming queries and searching for optimization objects. The long_query_time variable controls the maximum time limit, in seconds. It can also be set to ms, but patch is required.

As for security considerations, such as test database and online separation, backup, and Master/Slave, we will talk about it later, and the time is short. We will write so much about it first, To be continued...

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.