ExamVeda
Login
Home
This question belongs to MySQL MySQL Miscellaneous
MySQL Miscellaneous
?

Which of the following WHERE clauses are faster?
1. WHERE col * 3 < 9
2. WHERE col < 9 / 3

Answer & Solution
Correct Answer: Option B
This question is about how MySQL handles calculations in a WHERE clause. Think of it like this: MySQL wants to be as efficient as possible when searching for data.

In option 1, WHERE col * 3 < 9, MySQL needs to multiply every value in the 'col' column by 3 before comparing it to 9. This means it does extra work for each row.

In option 2, WHERE col < 9 / 3, MySQL only needs to do the calculation (9 / 3 = 3) once. Then, it can simply compare the 'col' column values directly to 3. This is much faster!

So the answer is Option B: 2. Option 2 is faster because it performs the calculation only once, while Option 1 performs a calculation for each row.
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.