Which MySql line is faster:
Posted
by Camran
on Stack Overflow
See other posts from Stack Overflow
or by Camran
Published on 2010-04-20T17:39:02Z
Indexed on
2010/04/20
17:43 UTC
Read the original article
Hit count: 197
I have a classified_id
variable which matches one document in a MySql table.
I am currently fetching the information about that one record like this:
SELECT * FROM table WHERE table.classified_id = $classified_id
I wonder if there is a faster approach, for example like this:
SELECT 1 FROM table WHERE table.classified_id = $classified_id
Wont the last one only select 1 record, which is exactly what I need, so that it doesn't have to scan the entire table but instead stops searching for records after 1 is found?
Or am I dreaming this?
Thanks
© Stack Overflow or respective owner