How MySQL Optimizes DISTINCT?



How MySQL Optimizes DISTINCT?..

Answer / Munnakumar

MySQL optimizes the DISTINCT keyword by eliminating duplicate rows as early as possible in the execution of a SELECT statement. To do this, it creates an intermediate temporary table with unique values and then selects from this table.nn- MySQL 5.6 or later versions use hash-based methods for optimizing DISTINCT queries with a smaller number of distinct values.nn- If the number of distinct values is large, MySQL will switch to a sort-based method (using sort_buffer_size and max_sort_length system variables) that sorts all rows first, then eliminates duplicates.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More MySQL Interview Questions

Describe mysql transaction properties.

1 Answers  


What is difference between oracle sql and mysql?

1 Answers  


What are the differences between a primary key and foreign key?

1 Answers  


How you will Show unique records.

1 Answers  


Is mysql relational?

1 Answers  


What is truncate command?

1 Answers  


How to delete the repeated records from a table?

1 Answers  


How to use in conditions?

1 Answers  


What is mysql architecture?

1 Answers  


Can python connect to mysql?

1 Answers  


In which format data is stored in mysql database?

1 Answers  


Explain MySQL locks?

1 Answers  


Categories