Mysql surface few questions

1, why must set a primary key?

  Because no primary key, innodb will help you generate a hidden column as the primary key increment. Anyway, should generate the primary key, the primary key can display their own designated spend primary key index to improve query efficiency.

2, the primary key is incremented or UUID (random)?

  Increment. innodb live primary key clustered index, if the primary key is incremented each time a new record is inserted, the recording will be added sequentially to a subsequent position of the current index node, automatic opening after a new page is filled. Is not auto-increment primary keys, it may insert in the middle, causing split pages, generate a lot of table fragmentation. In contrast, the increment insert better performance.

3, primary keys, why not have a business meaning recommend?

  Primary keys with business meaning there might be changes, causing page splitting, the creation of space debris.

4, do not indicate why the field enumeration enum type?

  enum type of order by low operating efficiency, the need for additional operations.

5. What type of monetary field use?

  decimal, float, and double as a binary storage, there are some errors, the accuracy will lead to misalignment.

6, why not direct high-capacity storage pictures, audio, video and other content?

  In practical applications we are using HDFS to store files, storing only the file path in mysql. Because large-capacity field type myssl only text and blob, but the memory temporary table mysql does not support text, blob such a large data type, if the query contains such data, you can not use memory temporary table sorting and other operations of the time, You must use a temporary table disk, resulting in slow query efficiency. And the data content of the General Assembly cause binlog contents, master-slave synchronization by binlog synchronization, will lead the master-slave synchronization problems efficiency.

 

Guess you like

Origin www.cnblogs.com/smallzhen/p/12615651.html