MySql recent interview summary

Due to the limited time today, and use the zookeeper api demo code written incorrectly, and therefore this article a little difficult labor, laugh cry ~. A summary of the entire interview here Mysql years ago. There are several other, Mysql aspects of the content of this introduction.

Second, the database (MySql) Part
1. There are table structure: student's name, course id, score three fields, how the students found the names average score greater than 85 points?
Answer: the SELECT student.id, student.stdentname, the AVG (student_score.score) the FROM A student_score the AS, Student
the WHERE student.id = student_score.studentid
the GROUP BY student_score.studentid the HAVING A> = 85
Reference: https: //www.cnblogs .com / yuanyuan2017 / p / 11376305.html

2.MySQL storage engine which
A: InnoDB, MyIsam, Memory, Merge , Archive, Federate, CSV, BLACKHOLE
difference 3.Mysql the storage engine InnoDB storage engine and MyIsam
1. InnoDB buffer will cache data and indexes, MyIsam only cache index
2. InnoDB supports transactions on the transaction, MyIsam does not support
the 3. locks for InnoDB to manage, support in the form of a variety of locks (table locks, row locks, page-level locking, etc.), MyIsam by mysql management, only supports table lock.
4. The data storage files are not the same, the data structure of the index are not the same
5. Of course, the query tables count data are not the same, InnoDB computing needs progressive scan count, the count MyISAM has been recorded, it can be returned quickly.
Reference: https: //www.cnblogs.com/yueshutong/p/10721896.html

What InnoDB storage engine underlying data structure 4.Mysql is?
Answer: B + tree (clustered index and non-clustered index) and adaptive Hash (the dictionary to find)
Related links: https: //blog.csdn.net/linjiaen20/article/details/85222088

5.Mysql storage engine is based on a table or library-based?
A: Based on the most obvious feature is the data table when the new tables which storage engine can be specified using the
Links: https: //www.cnblogs.com/fzz9/p/8968649.html

6. If there is a table x (a, b), has given a, b plus joint index (a, b) ask a = and b = a = and maybe you can hit the index???
A: You can hit the index, because a, b form a joint index following the index, b index, a, b index, the most left-principle (left prefix principle) may know that in both cases the index may hit the
links: https: //blog.csdn. NET / qq_42630887 / Article this article was / the Details / 97,113,323
https://blog.csdn.net/wdjxxl/article/details/79790421
analysis: this is actually a joint study of the use of index and MySQL leftmost principle (left prefix principle), author a little of this, but not considered in depth.

7. If there is a table x (a, b, c, d, e), has given a, b, c plus joint index (a, b, c) Will c =? And b =? And a =? A and ????? index = maybe be able to hit it that a = and b> and c = index can hit it (main pieces)
Answer:??? c = and b = and a = index could hit as Mysql will optimized to help a =? and b =? and c =? this form, so you can hit the index.
a =? may also hit the index.
a =? and b>? and c =? Only a hit index, the index is used as b> symbols lead to b, c index can not hit.
Because a, b form a joint index following the index, b index, a, b index, the most left-principle (left prefix principle) may know that in both cases the index may hit the
links: https: //blog.csdn. NET / qq_42630887 / Article This article was / the Details / 97,113,323
https://blog.csdn.net/wdjxxl/article/details/79790421

Under 8.MySQL why use the InnoDB storage engine B + tree index
A: 1. improve query and insert efficiency (reduce IO), to improve the efficiency of disk storage
2. You can achieve sequential and random access insert inserted access
analysis: here want to express meaning and usage scenarios is the difference between b and b + tree tree
Links:
https://www.cnblogs.com/tiancai/p/9024351.html
https://zhuanlan.zhihu.com/p/97601681

9. What is aggregated (clustered) index and non-clustered index
A:
clustered index: the physical order of rows and columns of data values (that is typically the primary key column) of the same logical order, a table can have a clustered index.
Non-clustered index: the index in the logical order of the index and the physical disk storage order different uplink, a table can have multiple non-clustered index.
Non-clustered index include: general index, the only index, full-text index
Related links: https: //www.cnblogs.com/sbb/p/8334593.html

10.MySQL back to the table what does this mean? Why back to the table? How to avoid back-table query?
A: The non-clustered index leaf node is still inode, but there is a pointer to the corresponding data block, use a non-clustered index if this query,
and the query column contains the index does not cover the other column, then he should be the first the second query, the query node data corresponding to the data lines.

If you do not check the query process of other non-indexed fields do not check, that check only indexed fields, to avoid back to the table to improve query speed.
Related links: HTTPS: //www.zhihu.com/question/347087093/answer/830934717
https://www.cnblogs.com/sbb/p/8334593.html

11.MySQL index coverage What does it mean?
A: The index covers means that if a query sql query on the full index of the column is not required back to the table, you can return to the index data.

12. What can be used where the B-tree
A: storing multilevel data

? 13.Mysql the implementation of a sql
A: first by the client-side sql statement incoming server mysql, mysql server has multiple layers, essentially independent of each other without affecting each layer,
service layer link, and then first there is determined by querying a data cache, and parsed by the parser sql syntax tree optimizer and actuators generate an execution plan, and finally by
providing data storage layer to read and write engine api actual reading and writing data
reference : https: //www.cnblogs.com/gusluo/p/11250863.html

14.Mysql bottom is B + tree? Why choose B + tree?
A: accurate to say that Mysql There are many types of storage engine, which InnoDB bottom using a B + tree, use B + trees can improve query and insert efficiency (reduce IO), to improve disk storage efficiency
in addition can be achieved sequentially inserted access and random insertion access

Published 164 original articles · won praise 70 · Views 350,000 +

Guess you like

Origin blog.csdn.net/u010504064/article/details/104238850