What do you do if you meet an interviewer who will deal with you?

Don't treat interviewers as gods, because they don't know the answers to many questions. Even what he knows is the wrong answer, and the question he is asking you now may be a technical problem he is facing now.

What do you do if you meet an interviewer who will deal with you?

I met an interviewer today, and he thought he was right. In fact, he is only to deal with you when there are a lot of people in the interview.

Question: Joint index, a joint index of the three fields a, b, and c. index(a,b,c), now I use b,c to search where, will the index be used?

I said maybe not, the interviewer said, you are wrong. The index will be used, so go down and review it again. I still want to explain, but the interviewer was a bit disgusted. Go down and take a look at the joint index.

I mainly have a good temper, otherwise, I just leave.

Now, let's just look at the demo, the evidence speaks.

What do you do if you meet an interviewer who will deal with you?

Create a table statement as shown above, and then add a few pieces of test data.

What do you do if you meet an interviewer who will deal with you?

Then, EXPLAIN.

What do you do if you meet an interviewer who will deal with you?

A screenshot of the execution plan is as follows:
What do you do if you meet an interviewer who will deal with you?

What if I use b,c?

What do you do if you meet an interviewer who will deal with you?

The execution plan is as follows:

What do you do if you meet an interviewer who will deal with you?

It is equivalent to a full table scan.

By analogy, you can use (b,c), (a,c), (c,a), (c,b) and other combinations to try again. You will find that there is a rule, the leftmost matching principle. index(a,b,c) is equivalent to index(a), index(a,b), index(a,b,c) three indexes.

According to our table above, we execute:

What do you do if you meet an interviewer who will deal with you?

You will find that only the first one can use the index, and the other two cannot be searched according to the index.

However, at this time, you must never come to a conclusion, saying: The second and third queries will not be indexed. Because there is a situation, they will still take the index, that is, when there are only three fields a, b, and c in the table.

So, when answering questions, don't be like me, answering so affirmatively. Let me talk about a vague answer. Do not go to the index, optimize SQL and look at EXPLAIN, don't memorize it by rote. Then, besides, if I remember correctly, what should I do?

Sometimes, when there are many people interviewing together, it is very likely that you will find someone to deal with you. Because the real interviewer is too busy. What would you do in this situation? Welcome to leave a comment!

Guess you like

Origin blog.51cto.com/15127565/2664943