In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
How to understand these five private statements of MySQL, aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
MySQL is a very popular relational database. Although most of the SQL syntax conforms to the ANSI SQL standard, it still carries a lot of excellent, private statements and indicators. Let's analyze it today.
EXPLAIN
Difficulty index: ★ ★
Recommended index: ★ ★
When our website or interface is visited more and more frequently, if our relevant SQL statements are executed for a long time, it is easy to cause slow response of the website or interface. By using the MySQL statement, we can clearly know how our SQL statement is executed, how many records are queried by executing a query statement, what tables are used and what the link order of multiple tables is. The query uses which indexes and other information, with this information, we can optimize our database according to multiple execution and analysis. If the index is established, the index that should be deleted will be deleted.
FOR UPDATE
Difficulty index: ★ ★ ☆
Recommended index: ★ ★
Sometimes we have a situation where we need to lock the row queried by a SELECT statement to prevent other clients from modifying it, so we can use this indicator to do so.
DELAYED
Difficulty index: ★ ★ ☆
Recommended index: ★ ★
Sometimes it is found that an insert or update operation of our product does not need to take effect immediately, that is, some applications with high reading requirements and low writing requirements can use this indicator, that is, the inserted or modified data is not immediately written to the disk file, but wait until the MySQL database is very idle. This indicator is also a small optimality indicator.
SQL_CACHE
Difficulty index: ★ ★ ☆
Recommended index: ★ ★
Sometimes our products have a lot of read operations and low frequency of modification, so at this time we can specify the sql_cache indicator when executing the select query, so that the query statement and the corresponding query results will be cached. Then the next time the same query statement is executed, if the data has not changed, the cached results will be returned directly to the client. This query statement indicator is mainly used for optimization operations in some feature application scenarios.
ON DUPLICATE KEY UPDATE
Difficulty index: ★ ★ ☆
Recommended index: ★ ★
We know that there is a special statement in MySQL is the Replace statement, that is, when we insert, we find that the data of a certain condition (here it refers to a * index or primary key) already exists, then delete the data first, and then insert the new data, that is, delete and then insert, but sometimes all we need is If it exists to just change the value of a field instead of deleting and inserting it, you can use ON DUPLICATE KEY UPDATE to do so at this time.
Reasonable use of the knowledge described above will certainly solve most of the problems in MySQL, including part of the performance analysis and optimization.
This is the answer to the question on how to understand the five private sentences of MySQL. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 239
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.