March 13, 2008 at 8:17 pm
i have a basic doubt.
lets assume we have 2 tables.
table1 has feilds id, name, age, sex, hieght, weight
of which name and id are primary keys.
table2 has fields name, id, address
of which name and id are primary keys.
now if i want to get address,age of everyne
i can run queries
1)select address, age from table2 t2, table1 t1 where t1.name = t2.name and t1.id = t2.id
2)select address, age from table2 t2, table1 t1 where t1.name+t1.id= t2.name+t2.id
both queries give the same result. i wanted to know which will be faster.
can anyone help. thanks in advance
March 13, 2008 at 9:06 pm
Sounds a bit like homework or an interview question, but I'll bite...
In the presence of the correct indexes (composit primary key), the first one will probably be a little faster because it does no calculations on the indexed columns. Of course, how hard would it be for you to actually setup a test? 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply