Page 1 of 1

SQL Working time and php

Posted: Thu Sep 24, 2009 9:36 am
by Komp
Hey guys,

I've been thinking about what kinds query are faster and what kinds of query are slower in general terms?

Example:

What would be faster:
1)
SELECT id FROM table_name WHERE email = 'example@email.com'
SELECT address FROM another_table WHERE id_person = 'some id'

OR

2)
SELECT a.id, b.address FROM table_name a, another_table b WHERE a.email = 'example@email.com', b.id_person = 'some_id'

In this case we've got 2 queries performed seperatly and the same result in only 1 query.
I know, this example, just like that, almost doesn't make sense, this is an example only!

May be there are some queries I should avoid using?

If I'm missing something, please tell me and/or correct me :)

I am really newbe at this...

Thanks for your help :wink:

Re: SQL Working time and php

Posted: Thu Sep 24, 2009 11:59 pm
by iamngk
Do you have mysql manual? If yes, kindly go through following topic.
7.2. Optimizing SELECT and Other Statements
It will give you clear idea in different type of query.

Re: SQL Working time and php

Posted: Fri Sep 25, 2009 12:06 am
by Griven

Re: SQL Working time and php

Posted: Fri Sep 25, 2009 11:47 am
by Komp
got it!

Thx guys :D