Which query is Faster and why? Their results is same. | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Which query is Faster and why? Their results is same.

SELECT * FROM MyTable; SELECT * FROM MyTable WHERE ID > 0

9th Apr 2019, 12:00 PM
gok han
gok han - avatar
5 Respuestas
+ 3
I think unless you have records having ID field value less than or equal to zero these queries will fetch the same amount of data, meaning they carry equally weighed task, none is any faster than the other.
9th Apr 2019, 3:15 PM
Ipang
+ 3
What if no record was found to match the condition? or the other way around, if all records match the condition? Logically, when a secretary was asked to collect all the clients' files, she gets them all faster than if she was told to collect clients' files with a condition, where she checks each file to verify whether the file match the required condition. It doesn't differ that much with how database server works in filtering data IMHO.
13th Apr 2019, 6:35 AM
Ipang
+ 2
Not if your table has records having `ID` field value less than or equal to zero. When you set a condition it means there are evaluation done on each record to filter out records that match criteria. Evaluation means extra work, which means more time.
12th Apr 2019, 3:40 PM
Ipang
+ 1
Without condition you take all data table, also it not use id for getting data. Condition help you to get faster.
12th Apr 2019, 11:36 PM
gok han
gok han - avatar
0
Second is faster then first coz one or more condition makes query faster
12th Apr 2019, 3:32 PM
gok han
gok han - avatar