Is Tencent so good? MySQL speaks clearly (basic + optimization + architecture)

Is Tencent so good?  MySQL speaks clearly (basic + optimization + architecture)

Einstein said, "Patience and perseverance will always get paid." I have always regarded this as my motto, and this motto has been completely realized in "me" this year.

Every programmer has a dream of a big factory, and I am no exception. I was asked by MySQL last year when I interviewed Ali. Many related questions were not answered, and it was only two-sided. Made a lot of preparations for the interview, collected a lot of questions about MySQL interview

What are the features of MySQL?

  1. Written in C and C++, and tested with a variety of compilers to ensure the portability of the source code
  2. Support AIX, FreeBSD, HP-UX, Linux, MacOS, Novell Netware, OpenBSD, OS/2 Wrap, Solaris, Windows and other operating systems
  3. Provides API for multiple programming languages. These programming languages ​​include C, C++, Python, Java, Perl, PHP, Eiffel, Ruby and Tcl.
  4. Support multi-threading, make full use of CPU resources
  5. Improved SQL query algorithm, effectively improving query speed
  6. It can be used as a separate application in the client-server network environment, and can also be embedded into other software as a library to provide multi-language support. Common encodings such as Chinese GB 2312, BIG5, Japanese Shift_JIS, etc. Can be used as data table name and data column name
  7. Provide multiple database connection methods such as TCP/IP, ODBC and JDBC
  8. Provide management tools for managing, checking, and optimizing database operations
  9. Can handle large databases with tens of millions of records

Step into the world of MySQL

1. 21 best practices for MySQL performance optimization

  1. Optimize your queries for query caching
  2. EXPLAIN your SELECT query
  3. Use LIMIT 1 when only one row of data is required
  4. Index the search field
  5. Use a similar type of example in the Join table and index it
  6. Never ORDER BY RAND()
  7. Avoid SELECT *
  8. Always set an ID for each table
  9. Use ENUM instead of VARCHAR
  10. Get advice from PROCEDURE ANALYSE()
  11. Use NOT NULL whenever possible
  12. Prepared Statements
  13. Unbuffered query
  14. Save the IP address as UNSIGNED INT
  15. Fixed-length tables will be faster
  16. Vertical split
  17. Split large DELETE or INSERT statements
  18. The smaller the column, the faster
  19. Choose the right storage engine
  20. Choose the right storage engine
  21. Beware of "permalinks"

Is Tencent so good?  MySQL speaks clearly (basic + optimization + architecture)

 

2. Summary of MySQL interview questions

The previous Alibaba interview questions have been summarized, and the specific interview questions are organized into documents. This article is for the MySQL series, so the following only shows some of the MySQL problems that I was asked when I interviewed Ali for the first time. This year, Ali encountered a problem with MySQL in the interview.

2.1. Documents for other topics (including answers) can be received by privately mailing me [Interview].

  1. Please explain the concept and main features of relational database?
  2. Please tell us the typical products, characteristics and application scenarios of relational databases?
  3. Please describe in detail the SQL statement classification and corresponding representative keywords.
  4. What is MySQL multi-instance and how to configure MySQL multi-instance?
  5. How to strengthen MySQL security, please give specific feasible measures?
  6. A SQL statement in the drop library was executed by mistake. How to recover completely?
  7. Describe the principle of MySQL master-slave replication and the complete steps to configure master-slave.
  8. How does MySQL realize bidirectional master-slave replication and explain the application scenarios?
  9. How does MySQL realize cascading synchronization and explain the application scenarios?
  10. How to solve MySQL master-slave replication failure?

2.2. How many questions can you answer for MySQL 55 interview topics?

  1. A table with an ID self-incrementing primary key. After inserting 17 records, delete the 15, 16, 17 records, restart Mysql, and insert a record. Is the ID of this record 18 or 15?
  2. What are the technical characteristics of Mysql?
  3. What is Heap table?
  4. What is the default port of Mysql server?
  5. Compared with Oracle, what are the advantages of Mysql?
  6. How to distinguish FLOAT and DOUBLE?
  7. Distinguish between CHAR_LENGTH and LENGTH?
  8. Please briefly describe the names of the four transaction isolation levels supported by InnoDB in Mysql and the differences between each level?
  9. What is the usage of ENUM in Mysql?
  10. How to define REGEXP?
  11. What is the difference between CHAR and VARCHAR?
  12. What can be the string type of the column?
  13. How to get the current Mysql version?
  14. What storage engine is used in Mysql?
  15. What is the Mysql driver?
  16. What does TIMESTAMP do on the UPDATE CURRENT_TIMESTAMP data type?
  17. What is the difference between primary key and candidate key?
  18. How to log in to Mysql using Unix shell?
  19. What is myisamchk used for?
  20. What are the method commands for MYSQL database server performance analysis?
  21. How to control the maximum size of the HEAP table?
  22. What is the difference between MyISAM Static and MyISAM Dynamic?
  23. What is a federated table?
  24. If a table has a column defined as TIMESTAMP, what will happen?
  25. When the column is set to AUTO INCREMENT, what happens if it reaches the maximum value in the table?
  26. How can I find out which auto increment was assigned during the last insert?
  27. How do you see all the indexes defined for the table?
  28. What do% and _ in the LIKE statement mean?
  29. How to convert between Unix and Mysql timestamps?
  30. What is the column comparison operator?
  31. How do we get the number of rows affected by the query?
  32. Is Mysql query case sensitive?
  33. What is the difference between LIKE and REGEXP operations?
  34. What is the difference between BLOB and TEXT?
  35. What is the difference between mysql_fetch_array and mysql_fetch_object?
  36. How do we run batch mode in mysql?
  37. Where will the MyISAM table be stored and also provide its storage format?
  38. What are the different tables in Mysql?
  39. What is ISAM?
  40. What is InnoDB?
  41. How does Mysql optimize DISTINCT?
  42. How to input characters as hexadecimal numbers?
  43. How to display the first 50 rows?
  44. How many columns can be used to create an index?
  45. What is the difference between NOW() and CURRENT_DATE()?
  46. What kind of objects can be created using the CREATE statement?
  47. How many TRIGGERS are allowed in Mysql table?
  48. What is a non-standard string type?
  49. What are common SQL functions?
  50. Explain the access control list
  51. Does MYSQL support transactions?
  52. What field type is good for recording currency in mysql
  53. Under what circumstances are MYSQL data tables easily damaged?
  54. What are the mysql tables about permissions?
  55. What kind of locks are there in Mysql?

3. MySQL performance tuning and architecture design

  • Basic articles:
  1. Basic introduction to MySQL
  2. MySQL architecture composition
  3. Introduction to MySQL storage engine
  4. MySQL security management
  5. MySQL backup and restore

Is Tencent so good?  MySQL speaks clearly (basic + optimization + architecture)

 

  • Performance optimization articles:
  1. Related factors affecting the performance of MySQLServer
  2. MySQL database locking mechanism
  3. Optimization of MySQL database query
  4. Performance optimization of MySQL database schema design
  5. MySQLServer performance optimization
  6. Common storage engine optimization

Is Tencent so good?  MySQL speaks clearly (basic + optimization + architecture)

 

  • Architecture design articles:
  1. Basic principles of MySQL scalable design
  2. Scalable design of MySQLReplication
  3. Data segmentation for scalability design
  4. Scalable design of Cache and Search..
  5. MySQLCluster
  6. Ideas and solutions for high-availability design
  7. MySQL monitoring of high availability design

MySQL architecture and history

Is Tencent so good?  MySQL speaks clearly (basic + optimization + architecture)

 

Compared with other database systems, MySQL is a bit different. Its architecture can be applied in a variety of different scenarios and play a good role, but it also brings some difficulties in selection. MySQL is not perfect, but it is flexible enough to adapt to demanding environments, such as web applications. At the same time, MySQL can be embedded in applications, and can also support various application types such as data warehouses, content indexing and deployment software, highly available redundant systems, and online transaction processing systems (OLTP).

After three consecutive articles, add the assistant VX: mxj94670 can receive the most complete MySQL documentation in history for free

Server performance analysis

Is Tencent so good?  MySQL speaks clearly (basic + optimization + architecture)

 

In our technical consulting career, the three most frequently encountered performance-related service requests are: how to confirm whether the server has reached the best performance, find out why a certain statement is not executed fast enough, and the diagnosis is described by the user as Some intermittent troubles with "pause", "stacking" or "stuck". This chapter will mainly answer these three questions. We will provide--some tools and techniques to optimize the performance of the whole machine, optimize the execution speed of a single statement, and diagnose or solve the problems that are difficult to observe (the users of these problems are often difficult to know the root cause, sometimes even very It is difficult to detect its existence).

Query performance optimization

Is Tencent so good?  MySQL speaks clearly (basic + optimization + architecture)

 

The previous is how to design the best library table structure and how to build the best index, which is essential for high performance. But these are not enough—a reasonable design of the query is needed. If the query is poorly written, even if the database table structure is reasonable and the index is appropriate, high performance cannot be achieved.

MySQL advanced features

Is Tencent so good?  MySQL speaks clearly (basic + optimization + architecture)

 

MySQL has introduced many advanced features from version 5.0 and 5.1, such as partitions, triggers, etc., which may not be unfamiliar to users with a background in other relational databases. These new features have attracted many users to start using MySQL. However, the performance of these features needs to be actually used by users to know. Here we will introduce to you how these characteristics behave in the real world, instead of simply introducing the data in the reference manual or Yichuan material.

After forwarding + following, pay attention to private message reply [architecture book] to receive the most complete MySQL actual combat document in history for free

Optimize server settings

Is Tencent so good?  MySQL speaks clearly (basic + optimization + architecture)

 

Here we will explain the process of creating a reliable configuration file for the MySQL server. This is a very winding process, with many interesting points and ideas worthy of attention. It is necessary to pay attention to these points, because the fastest way to create a good configuration is not from learning configuration items, nor from asking which configuration items should be set or how to modify, nor from checking server behavior and asking which configuration items can be Performance improvement begins.

It is best to start by understanding the MySQL kernel and behavior. Then you can use this knowledge to guide the configuration of MySQL. Finally, you can compare the desired configuration with the current configuration, and then correct important and valuable differences.

After forwarding + following, pay attention to private message reply [architecture book] to receive the most complete MySQL actual combat document in history for free

copy

Is Tencent so good?  MySQL speaks clearly (basic + optimization + architecture)

 

MySQL's built-in replication function is the basis for building large-scale, high-performance applications based on MySQL. Such applications use the so-called "horizontal expansion" architecture. We can synchronize data by configuring one or more standby database 1 for the server. The replication function is not only conducive to the construction of high-performance applications, but also the basis for high availability, scalability, disaster recovery, backup, and data warehouse work. In fact, scalability and high availability are usually related topics, which we will elaborate on in the next three chapters.

After forwarding + following, pay attention to private message reply [architecture book] to receive the most complete MySQL actual combat document in history for free

Scalable MySQL

Is Tencent so good?  MySQL speaks clearly (basic + optimization + architecture)

 

Here will show how to build-a MySQL-based application, and when the scale becomes larger and larger, it can ensure fast, efficient and economical. Some applications are only suitable for one or a few servers, so what scalability recommendations are related to these applications? Most people never maintain super-large-scale systems, and usually cannot be imitated in mainstream large companies The strategy used. This chapter will cover this series of strategies. We have established or assisted in the establishment of many applications, ranging from applications with a single or a small number of servers to applications using thousands of servers. Choosing a suitable strategy can greatly save time and money. MySQL is often criticized for being difficult to scale. In some cases, this view is correct, but if you choose the right architecture and implement it well, you can scale MySQL very well. But scalability is not-a well-understood Theme, so let's sort out the points that are easy to be confused.

After forwarding + following, pay attention to private message reply [architecture book] to receive the most complete MySQL actual combat document in history for free

MySQL in the cloud

Is Tencent so good?  MySQL speaks clearly (basic + optimization + architecture)

 

Application layer optimization

If you spend too much time on improving the performance of MySQL, it is easy to confine your vision to MySQL itself and ignore the user experience. Looking back, you may realize that perhaps MySQL has been optimized enough to account for a very small proportion of the response time users see. At this time, attention should be paid to other parts. This is a very good point, especially for DBAs, this is the right thing to do. But if it is not MySQL, what is causing the problem? Using the techniques mentioned in Chapter 3, the answer can be given quickly and accurately through measurement. If you can analyze the application from beginning to end along the logic process, it is generally not difficult to find the source of the problem. Sometimes, even though the problem is on MySQL, it can easily be solved in another part of the system.

Backup and restore

If you do not plan your backups in advance, you may find that you have missed some of the best options in the future. For example, after the server has been configured, I remembered that LVM should be used so that a snapshot of the file system could be taken but it was too late. When configuring system parameters for backup, you may not notice that certain system configurations have an important impact on performance. If there is no plan to do regular recovery exercises, when recovery is really needed, you will find that it is not so smooth.

MySQL user tools

The MySQL server distribution package does not include tools for many common tasks, such as tools for monitoring servers or comparing data between different servers. Fortunately, Oracle's commercial version provides some extended tools, and MySQL’s active open source community and third-party companies also provide a series of tools, reducing the need to "re-invent the wheel".

List

Is Tencent so good?  MySQL speaks clearly (basic + optimization + architecture)

After three consecutive articles, scan the bottom to get the most complete MySQL actual documentation in history for free

Guess you like

Origin blog.csdn.net/m0_46757769/article/details/112604063
Recommended