Jump to content
xisto Community
Sign in to follow this  
arcticsnpr

Too Many Mysql Queries? is it bad?

Recommended Posts

I know that querying the database multiple times in a script is bad, because it uses bandwidth. But what if you have practically unlimited? If you have too, is it ok to have many queries in one script?

Share this post


Link to post
Share on other sites

Hmm... I think you're a little confused. Assuming your MySQL host and web host share the one server (or at least, are on the one local network), it won't use any bandwidth no matter how many queries you execute, because the traffic never leaves the network and therefore is not counted. It's not until you start sending data to a user from your server that it will start to eat away at the bandwidth.

 

You can have as many queries as you like in a script. The only real limitation you may face is speed - if you attempt to execute a large number of complex SQL queries in one go, the server may take a while to process them and begin to slow down, particularly if you have very large databases. This may present something of a problem if your script carries out a lot of queries.

 

The only related problem I can think of is the number of connections a single MySQL host can handle at any one time. This is particularly a problem on shared webhosts that host thousands and thousands of different sites, all of which could be attempting to access a single MySQL host at any given time (some long-term members of Xisto may have seen this issue raised before). Poor coding practises can also lead to trouble, such as failing to clear query memory, close connections, etc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.