A quick review of MySQL: performance issues

Now look at the previous focus on providing optimized performance to explore (the following content does not fully determine the performance of MySQL):

  1. First, MySQL (with all DBMS) have the same specific hardware recommendations. In learning and research MySQL, using any old computer as a server can be. But for server-generated, the hardware should follow these recommendations.
  2. In general, the key production DBMS should be allowed on their own dedicated server.
  3. MySQL is a series of pre-configured default settings, these settings are usually a good start. But after some time you may need to adjust memory allocation, buffer size. (See currently set, use SHOW VARIABLES; and SHOW STATUS;).
  4. MySQL is a multi-user multi-threaded DBMS, that is, it often perform multiple tasks simultaneously. If one of the slow implementation of these tasks, all requests will be executed slowly. If you experience significant performance bad, you can use SHOW PROCESSLIST Show all active processes (and their thread ID and execution time). Also the end of a particular process by using the KILL command (using this name as the administrator login required).
  5. There are always written in the same SELECT statement is more than one way. We should test links, and sub-query to find out the best way.
  6. Use EXPLAIN statement MySQL to explain how it will execute a SELECT statement.
  7. Generally, a stored procedure performed faster than the one in which the pieces MySQL statement.
  8. You should always use the correct data type.
  9. Never retrieve the data even more than demand. That is, do not use SELECT * (unless really needed each column).
  10. Some operations (including INSERT) supports an optional DELAYED keyword, if you use it, will return control to the caller immediately, and once it is possible to actually perform the operation.
  11. When importing data, it should be closed automatically committed. You may also want to delete the index (including FULTEXT index), how to rebuild them after their import.
  12. Must index the database table to improve the performance of data retrieval. Determines the search description does not say a trivial task, need to analyze a SELECT statement used to find duplicate WHERE and ORDER BY clauses. If a simple WHERE clause to return the results take too long, you can determine which columns to use (or several columns) is subject to index.
  13. Your SELECT statement with a series of complex conditions OR you? By using multiple SELECT statements and connects them UNION statement, you can see significant performance improvements.
  14. The index to improve performance of data retrieval, but the damage data insert, delete and update performance. If there are some tables, they often are not searched to collect data, do not index them before not often searched. (Indexes can be added and deleted as required)
  15. LIKE very slow. In general, it is best to use FULLTEXT rather than LIKE.
  16. The database is constantly changing entity. A well optimized table for a while probably unrecognizable. Since the change and use the table of contents, the ideal optimization and configuration will change.
  17. The most important rule is that each rule under certain conditions will be broken.
Published 61 original articles · won praise 30 · views 20000 +

Guess you like

Origin blog.csdn.net/weixin_41800884/article/details/104066844