Basic understanding of MySQL storage performance optimization

Source: Internet
Author: User
Tags create index time limit mysql database

These days to learn about the MySQL database on the nature of the optimization and design content, now do a summary of their own learning, follow-up I will continue to study further, improve the following summary:

1. Use index

Up to 16 indexes per table to support multiple-column indexes and Full-text indexing

Build index: CREATE index index_name on users (username);

View index: Show index from users;

is a double-edged sword, build not indexed, mainly look at the function of the table, find a good balance point.

2. Use Explain analysis query

In the query using explain

Explain select *from users;

3, adjust the MySQL internal configuration

(1), change index buffer length (key_buffer);

It is recommended to set 25% of the total system memory.

(2), change the length of the table (read_buffer_size)

When a database scans a table frequently, MySQL allocates a memory buffer, and if it feels that the scan is too slow, it can be sized appropriately.

(3), set the number of open Table size (Table_cache)

This variable controls the maximum number of tables that MySQL opens at any time, thereby controlling the server's ability to respond to input requests. He's with max_connections.

(4), set a time limit on the slow query (Long_query_time)

Ysql has a "slow query log" that automatically records all of the queries that have not yet ended within a specific time span. This log is useful for tracking inefficient or misbehaving queries and looking for optimized objects. Long_query_time variable controls This maximum time limit, in seconds. can also be set to MS, but need to be patched.

As for security considerations, such as testing database and online separation, backup, master and subordinate, these follow-up talk, Time is pressing, write so much, 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.