Database Querying Philosopy

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
zoonose
Forum Newbie
Posts: 8
Joined: Wed Aug 29, 2007 7:44 am

Database Querying Philosopy

Post 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
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

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