Page 1 of 1

having several simple query or combine them into one query?

Posted: Fri Sep 05, 2003 4:35 pm
by maldar
I have some big queries that can spilt into few simple query.
but i'm worry :oops: by doing that, it increases server overhead :cry: when many users request it at the same time or at least increase time of carry it out.
i have many query in my project.
what do you think is better:
having several simple query or combine them into one query?
is there any rule for constructing queries? :?

Posted: Fri Sep 05, 2003 5:31 pm
by JAM
I would say "better one big thatn many small" but that depends on hardware, os, how code is written, what the database contains...

Also have in mind that making 20 queries, also tells php to connect, fetch and close the connection to the database 20 times.

Homework:
Make one page displaying the time (microseconds) at the top, loop 10 big queries (without output), and display the time again at the bottom.
Then do the same on another page, but loop many smaller queries matching the same result as the big on.

Then let us know what you come up with. ;)
Interesting subject.