MySQL Distributed Thinking (3) - Factors Affecting MySQL Performance by Performance Optimization

Factors affecting mysql performance
1. The impact of business requirements on performance
     -----> Business requirements need to be reasonable
     -----> Forum (small requirements)
               -----> Real-time statistics on the total number of posts select count( *) That is, if there are already tens of millions of records in the bid
        -----> such a query will consume a lot and become a performance bottleneck
        -----> the number of posts is dedicated to one table and one field To store it, then the table will become highly concurrent
                  , even if the innodb storage engine cannot, because of the row lock, and the post data has only one row. Unable to cope with high concurrent operations, it will become a bottleneck
     -----> A lot of statistical information is quasi-real-time rather than real-time statistics
              -----> Some quantity information, paging information, sorting information, etc. of the website are
                 generally not Real-time but quasi-real-time.
     ----->There should be an internal assessment to assess whether the demand is reasonable
               ----->When the product manager proposes a new demand, he must give the expected income index, so as to calculate the input-output ratio after going online.
        ----->In the process of the project, the input (people, hardware, etc.) should be recorded in detail
        ----->The actual income value after going online
        ----->Summary some rules and laws
2. System Architecture (storage architecture) and the impact of implementation on performance
    ----> The data storage architecture should be reasonable (will be explained in detail later --->
           ----> Reasonable architecture is the best way to get help, and then other aspects of optimization
    ----> Is your data suitable to be placed in mysql
          ----->Flow queue data
   ----->Binary Multimedia data
   ----->Large text data
   ----->Other files, pictures, etc
    .----->Whether to do proper caching
            ---->Whether database access and frequent data are done Hotspot cache
     ---->Whether the cache of the database server itself is reasonably used
     ---->what kind of data is placed in the cache
              ---->hotspot data
       ---->system configuration and rule
       data-- -->Basic information data of active users
       ---->Quasi real-time statistical information data
       ---->... ....
    ----->Database design, implementation of data query statement, etc.

 3. The impact of query statements on database performance (will be explained in detail later)
        ----> Developers can't just focus on the query results and not on the query process
       ---> Example: Each user queries their own album list (assuming that each column displays 10 photos), can have a message after the photo,
                    we want to check the number of messages.
      ---> Scheme 1: select id, subject, url from photo where user_id=? limit 10
                        Loop through the result of the first step 10 times and execute select count(*) from photo_comment where photo_id=?
                          ---> Scheme 2: 
                        The first step is the same as the above. The
          second step is to assemble the 10 photo_ids obtained above through the program,
          select photo_id through in query, count(*) from photo_comment where photo_id in(?)group by photo_id "
             Get all replies for 10 photo_id at once

    ----> Scheme 2 of the brief analysis is simpler.
 -----> In the future, you will need to look at the execution plan and performance loss (cpu, io loss)
 -----> You need to understand the principle of the entire mysql query, performance loss, etc. will be detailed in subsequent chapters explain.
4. The impact of Schema design on system performance (will be explained in detail in subsequent chapters)
      ----> Forum post case (assuming it is now a forum system with high concurrency)
              ----> Where is the highest concurrency of the forum with high concurrency?
                  -----> The highest concurrency is to view the list of post titles. Now, the post title is often followed by an author's nickname
              . Here, a join query is required
           -----> Join should not be used in high concurrency operations Query
    -----> We will redundantly store the author's nickname in the post table
                 ----> Violation of the paradigm ----> The current design often uses a combination of paradigm and non-paradigm


5. The impact of the hardware environment on the performance of the database
    ---->How to choose a server
          ---->What are the standards for adding the latter to purchase a database server
             ---->Many enterprises need to be put forward by the responsible person when purchasing a server How to write the program.
          ----->Understand TPC
               ----->TPMC--- measure the processing power of the server

    ----->How to choose specific hardware
              ---->OLTP system
                 ---->The amount of concurrency is large, the overall data volume is large, the data accessed each time is small, the access data is relatively discrete,
           there is active data and the proportion Not much.
          ----> Large memory active data can be Cached, frequent access and less data access each time,
           so the IOPS performance of the disk is better, and the throughput is secondary. High concurrency, high CPU requirements,
    frequent network interactions, high network equipment requirements
     ------> OLAP systems
                ----> large amount of data, few concurrent accesses, each access needs to retrieve more data, access Concentrated,
                 no obvious active data
         ----> as much disk throughput as possible, not much concurrency, low CPU requirements.

    ----->Summary: According to the characteristics of your own system, you should choose a more suitable and cheaper hardware device.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326994827&siteId=291194637