what is faster query ?
select Name from Worker
or
select TOP(1) Name from Worker
I have 1,000,000 records
thank's in advance
If you don't have an ORDER BY or a DISTINCT, SELECT TOP(1) Name FROM Worker
is faster.
The reason for this is that if you do happen to have an ORDER BY or a DISTINCT, the query has to go through the entire table to sort and filter out unwanted results. If it's a straight SELECT TOP, however, it can go to the first page, take the first row, and be done with it very quickly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With