View Full Version : One Query Compared to Three

18 Apr 2008, 19:22
Is there a large difference between running three queries or one?

I have a script I wrote, and I can do it in three queries and it works perfectly -- I think I can do it in one (or maybe two) if I thought it out a little more ... however, that would be a lot of joins and some other stuff.

My question is ... from a load standpoint ... is there a really significant reason to change it and do it in one instead?

Just curious what everyone thought.

18 Apr 2008, 20:44
It depends on how often those queries are going to be run. If they get run on every thread and you have 3000 users on the site at a time, that could add up. However, if it is only run on your members page and you only have 10 users on at a time, it will probably make no difference at all.

18 Apr 2008, 20:49
Usually if you can combine the queries with joins - you should. MySQL is efficient at joining relational tables.