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)06/01 Report--
This article mainly introduces MySQL storage process and transaction advantages and functions, the content of the article is carefully selected and edited by the author, with certain pertinence, the reference significance for everyone is still relatively large, the following with the author to understand the advantages and functions of MySQL storage process and transactions.
Storage process:
Advantages:
1. Fast execution speed. Especially for more complex logic, reduce the consumption between network traffic, another important point is that stored procedures are compiled only when created, after each execution of stored procedures do not need to recompile, and general SQL statements are compiled once every time they are executed, so the use of stored procedures can improve the execution speed of the database.
2. Improve work efficiency. Simple to write programs, using stored procedure call class, call any stored procedure as long as 1-2 lines of code.
3. Standardized program design, easy to upgrade and maintain.
4. Improve system security. You can set that only a user has access to a specified stored procedure.
Projects with small amounts of data, or those that have nothing to do with money, can function without storage. Mysql's storage procedures have yet to be tested in practice. If it is a formal project, it is recommended that you use sql server or oracle stored procedures. Data-to-data processing is much faster than programming.
Disadvantages:
Part of the program function moved into the database, destroying the CVM three-tier structure design.
Services:
There can be stored procedures in a transaction and there can be transactions in stored procedures.
When is it appropriate to use stored procedures?
1. When a service processes multiple tables at the same time, it is appropriate to use stored procedures.
2, complex data processing with stored procedures, such as some report processing.
3, multi-condition multi-table joint query, and do paging processing.
When is it appropriate to use transactions?
Every time a transaction is used, it takes some overhead. In addition, transactions may lock rows of some tables. Therefore, unnecessary transactions result in performance loss. There is a rule that transactions are used only when the operation requires them. For example, if you query only a few records from a database, or if you perform a single query, you don't need an explicit transaction most of the time because the declarations are already encapsulated in an implicit transaction. However, as mentioned earlier, it's important in multi-declarative updates because transactions can actually speed things up. Similarly, if there is a choice between saving milliseconds or compromising data integrity, the right answer is to keep your data clean and not worry about the milliseconds.
Another caveat before using transactions is to keep them as short as possible. Avoid using SELECT return data in transactions unless the statement depends on the return data. If you use SELECT statements, select only the rows you want, so don't lock too many resources while maintaining the highest possible performance. In the case of schema order, remove all SELECT statements from the transaction. This is done because the transaction locks all the data rows being manipulated during processing, which affects the execution of other concurrent sql statements.
After reading the above about MySQL storage process and transaction advantages and functions, many readers must have some understanding, if you need to obtain more industry knowledge information, you can continue to pay attention to our industry information column.
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: 0
*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.