Free pointsInterviewer : Have you ever used Linux? Me : Yes Interviewer : I want to check the memory usage. What command should I use? Me : Interviewer : Then tell me what information you can see using the free command Me : Well, as shown in the figure below, you can see the usage of memory and cache
Interviewer : Do you know how to clean up the used cache (buff/cache)? Me : em… I don’t know Interviewer : Me : (Free points, very happy) There are great benefits. By clearing the cache, we will have more available memory space, just like the little rocket of xx guard on PC, click it and it will release a lot of memory. Interviewer : Em..., go back and wait for notification SQL JoinInterviewer : Let's change the topic and talk about your understanding of join. Me : OK (If I answer wrong again, it will be all over, so I’ll seize the opportunity) review The Interviewer : If you need to use Me : There are two situations, small data scale and large data scale. Interviewer : And then? Me : For
Interviewer : So we can conclude that Me : Yes Interviewer : Why? BufferMe : When executing a join statement, there must be a comparison process. Interviewer : Yes Me : Comparing two tables one by one is slow, so we can read the data from the two tables into a As shown in the figure below, the size of Interviewer : Besides that? A major premiseMe : Any project will eventually go online, and it is inevitable to generate data, and the scale of data cannot be too small. Interviewer : That’s right. Me : Most of the data in the database will eventually be saved to Take MySQL's InnoDB engine as an example
verify Me : This means that we need to read as many files as we have to connect to the tables. Although we can use indexes, we still have to move the hard disk head frequently. Interviewer : So frequent head movement will affect performance, right? Me : Yes, don’t the current open source frameworks like to say that they have greatly improved performance through sequential reading and writing, such as Interviewer : That's right. Do you think Me : Why is the cache taking up more than 1.2G? Interviewer : Have you ever thought about
Taste, taste carefully After thinking for a few minutes Me : If you just release the memory used by Interviewer : Not entirely true. Me : Could it be? I remember a sentence in "CSAPP" (In-depth Understanding of Computer Systems)
Translated into human language, it means that Linux will treat the memory as a hard disk cache Interviewer : Now you know how to answer that easy question, right? Me : I… Join AlgorithmInterviewer : Let me give you another chance. If I ask you to implement the Join algorithm, what would you do? Me : If there is no index, nested loops will do the trick. If there is an index, you can use it to improve performance. Interviewer : Let’s talk about Me : During the scan process, the database will select a table and put the data it wants to return and compare with other tables into Interviewer : How do you handle it when there is an index? Me : This is relatively simple. Just read the index trees of the two tables and compare them. I will introduce the method of dealing with no index. Nested Loop Join Nested loops only read one row of data in the table each time. That is to say, if outerTable has 100,000 rows of data and innerTable has 100 rows of data, it needs to be read Of course, no database engine uses this algorithm now (too slow) Block nested loop MySQL InnoDB uses this algorithm when no index is available. Consider the following two tables When the join operation cannot be performed using the index, InnoDB automatically uses the Summarize When I was in school, the database teacher liked to test me on database paradigms. It was not until I started working that I learned that performance should be the basis for everything. If redundancy is possible, then use it. If it is really not possible, then This concludes the article on why code standards require SQL statements not to have too many joins. For more information on why SQL statements should not have too many joins, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: CSS code to distinguish ie8/ie9/ie10/ie11 chrome firefox
>>: The difference between the name and id of the a tag's target pointing to the iframe
Table of contents Preface first step: Step 2: Mod...
1. Business Scenario I have been doing developmen...
The so-called three-column adaptive layout means ...
1. Add fields: alter table table name ADD field n...
Two problems that are easy to encounter when inst...
My environment: 3 centos7.5 1804 master 192.168.1...
Abstract: HBase comes with many operation and mai...
1. Previous versions yum remove docker docker-cli...
The Spring Boot project uses docker containers, j...
Usually a CSS selector selects from top to bottom...
Table of contents Vue CLI builds a Vue project Vu...
Hello everyone, today I will share with you the i...
Table of contents 1.1 Java environment as a prere...
We better start paying attention, because HTML Po...
Docker has been very popular in the past two year...