Page 1 of 1

Database Querying Philosopy

Posted: Wed Aug 29, 2007 7:48 am
by zoonose
I have a question on philosophy or rationale of MySQL usage with PHP.

I have setup a script to enter event dates from a user submitted form. This forms allows for repeating dates. So i have decided to make my script evaluate all the possible dates and enter them into a database.

Now, my question arises when i created a looping function to cycle through the possible dates.

Should i have the function add each date one at a time into the database providing numerous connections to the database, or should i store them as an array and submit them to the database once the dates have been calculated??

i.e. Would it be better to have a LOT of SMALL connections to MySQL
or
would it be better to have a FEW LARGE connection to MySQL

in terms of speed, server load, and basic principles of databasing??

any help appreciated,

cheers,

zoo

Posted: Wed Aug 29, 2007 11:57 am
by Begby
Its generally better to have one large query rather than a lot of small ones. There is overhead involved in creating the query and getting the results and their should be a very noticeable difference in doing 1000 queries vs. 1 query with 1000 records.