Acquaintance mysql architecture design

First, the application interacts with the system, how to conduct a mysql?

  Jdbc time came into contact with, and how our system to complete a sql does it work? The first step, to establish a database connection; the second step, the operation sql; a third step of releasing the connection.

  

 

 

  But each time to establish connection to the database is very time-consuming and resource, so we added the concept of connection pooling. The first step is to get access to the connection from a connection pool available, the third step of releasing the connection is not disconnected, but the connection back into the connection pool.

 

 

  But how to deal with sql mysql every time we submit it? Previously this was a black box for me, I only know the results of the operation to mysql just fine, but there are problems time and the problem can not be analyzed in what step. Today began in-depth look at mysql, rather than just a simple curd.

Second, what is the mysql

  First, what mysql that? In fact, it is a system, and our other business systems, composed by the code line by line. Our own system and mysql interactive, is a http interface calls through it, there are connections to interface with the interface queries and so on.

      mysql systems, like the rest of us also maintains a thread pool, other business systems used to get connected. mysql there is a monitor thread, we have been monitoring what's new connection requests over. Once a request is over, calls the sql interface operation.

 

 Third, once the process SQL operations   

   So a SQL operation process is how it?

     比如 select id,name from user where id=1:

     1.SQL parser sql. This will resolve to sql This is a select query, table name, user operations, field id query, name.

     2.SQL optimizer optimize sql. After sql parsing out the steps to follow what kind of operation it? Full table scan is filtered off piece id = 1, or is positioned to that specified according to an id = 1, query the data piece out of it. Clearly, the latter method is more optimized.

     3.SQL actuators implementation plan. How to execute sql, it is to rely on the SQL executor.

     4.调用存储引擎接口执行sql。存储引擎操作存放在内存或磁盘的数据,进而返回我们需要的结果。mysql的存储引擎有innodb,myisam等,现在用的最多的就是innodb了。

      

  

 

 

Guess you like

Origin www.cnblogs.com/ITyannic/p/12233473.html