having several simple query or combine them into one query?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
maldar
Forum Commoner
Posts: 49
Joined: Mon Aug 18, 2003 4:39 pm

having several simple query or combine them into one query?

Post 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? :?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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.
Post Reply