SQL query - the cost of using DISTINCT

Does DISTINCT have a big impact on the query cost of a SQL query execution plan?

On a table with 100,000 lines, what's the difference between them:

select * from TABLE

and

select distinct(*) from TABLE 

in milliseconds?

+4
source share
1 answer

Typically, the answer is many milliseconds. select distinctequivalent to execution group byfor all columns. It is unlikely that you have an index in all columns, so an index will usually not be very useful.

, , distinct primary key. , .

, , select distinct, .

+2

All Articles