MySQL base module face questions

MySQL implementation of internal execution of a query?

1. The client through a first connector to connect to the server Mysql.

2. The connector after verification by the authority, first check whether there is a query cache. If this statement had been performed before the cache, the cache data is returned directly, or directly into the analyzer .

3. The analyzer will query parsing and lexical analysis to determine whether the correct SQL syntax. If the query syntax error in the error message is returned directly to the client. If the syntax is correct then enter the optimizer .

4. optimizer to optimize query processing, for example, a table contains a plurality of indexes, which index the optimizer will perform better judgment.

5. optimizer implementation of End to enter the actuator , the actuator starts executing a query statement than the right, until all the data to meet the conditions of the inquiry is completed, and then return the data.

MySQL prompt "This column does not exist" is a node to which the implementation quoted?

This error is executed to the analyzer stage, because at this stage Mysql will check the correctness of SQL statements.

MySQL query cache function of what the advantages and disadvantages?

MySQL query cache function occurs after the connector links MySQL server.

Advantages: high efficiency, if the cache buffer data directly returns.

Cons: too often lead to failure of the cache hit rate is relatively low, the operation will clear any updates table query cache, query cache thus resulting in very easy to fail.

How to shut down the MySQL query cache function?

MySQL query cache is enabled by default, configured Query Cache of the type parameter DEMAND (on-demand) close the query cache.

After 8.0 MySQL query cache delete function.

MySQL database engine, you can set the level for the table? How to set?

You can set different engines for different tables. This table is set using the engine = Engine storage engine name (such as Memory) in the create table statement.

The complete code is as follows:

create table student(
   id int primary key auto_increment,
   username varchar(120),
   age int
) ENGINE=Memory

What are the common engine for MySQL?

MySQL is commonly used engines InnoDB , MyISAM , Memory and so on.

MySQL 5.5.5 version start InnoDB has become the default storage engine

Commonly used storage engine InnoDB and MyISAM What is the difference?

InnoDB and MyISAM biggest difference is InnoDB supports transactions, while MyISAM does not support transactions.

The main difference:

1.InnoDB supports secure recovery after a crash, MyISAM does not support secure recovery after a crash.

2.InnoDB supports row-level locking, MyISAM does not support row-level locking, only support to a table lock.

3.InnoDB support foreign keys, MyISAM does not support foreign keys.

4.MyISAM performance than InnoDB.

5.MyISAM support full-text index FULLTEXT types, InnoDB does not support full-text index FULLTEXT type, but you can use sphinx InnoDB plugin supports full-text indexing and better.

6.InnoDB primary key query performance than MyISAM.

What features have InnoDB?

1. Insert buffer (insert buffer): the insertion and non-clustered index is updated, not directly into each index page, but instead first determines whether the inserted non-clustered index page in the buffer pool, if, directly inserted, otherwise, insert first into a buffer. This non-aggregated like spoofing index database has been inserted into the leaf node, then a certain frequency insertion merge operations and non-clustered index on page buffer child node, then insert a plurality of generally can merge into one operation, which greatly improves the performance of insertion and modification operations to non-clustered index.

2. The two write (double write): InnoDB wrote twice to bring reliability, mainly used to solve the partial write failure (partial page write). doublewrite two parts, part doublewrite Buffer memory, the size of 2M, another part table is shared space on a physical disk 128 contiguous pages, i.e. two regions, the same as the size of 2M. When the refresh buffer pool operation, the hard disk is not write directly, but by the memcpy function to copy the dirty pages to doublewrite buffer memory, and then subdivided by two write doublewrite buffer, 1M each write to a shared space table on the physical disk, and then immediately call fsync function, synchronous disk. As shown below:

3. adaptive hash index (adaptive hash index): Because InnoDB does not support hash indexes, but very high in some cases hash index of efficiency, so there adaptive hash index functions, InnoDB storage engine will monitor the indexes on the table Find, if observed when building hash indexes can improve the performance, then automatically create hash index.

A table has increased from three data, delete the data after two to restart the database, and then add a data, this data ID at this time is a few?

If this table engine is MyISAM, then the ID = 4, so if it is InnoDB ID = 2 (versions prior to 8 MySQL).

MySQL in what circumstances would lead to auto-increment primary keys can not be continuously?

The following situations will cause MySQL auto-increment primary keys can not be continuous:

Unique primary key violation will lead to increment primary keys discontinuous

Transaction rollback can lead to auto-increment primary keys discontinuous

Guess you like

Origin www.cnblogs.com/alinbling/p/11600897.html