Posted on: 10/01/03 11:25am
By: Anonymous (Tulkas)
I was digging through the code, today, and noticed that each and every query opens and closes its own database connection. Isn't this a little overkill? For a page with a lot of queries, this means that a database connection is opened and closed many times during the load process of that one page.
I believe that my site is getting some poor results, from this, and my provider (dreamhost) limits the number of database connections a site can have.
Actually, they assign 25 "points" for every connection you open, and 1 "point" for every query, so one geeklog query is actually 26 points. I have a limited number of points allocated to me for each month.
So, with the current system, it seems like many pages will cost well over 100 points to load, when they could theoretically be done in under 40.
Have you thought about opening a database connection at the top of each page (include the code in some header), perform all the queries for that page using that connection, and then close the connection in the footer of the page? It seems like that would be much more efficient.
Please correct me if I am wrong.
Thanks.
Re
atabase connection suggestion
Posted on: 10/01/03 03:05pm
By: Dirk
To quote from the
PHP manual[*1] :
If a second call is made to mysql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned.
bye, Dirk
Re
atabase connection suggestion
Posted on: 10/01/03 03:09pm
By: Anonymous (Tulkas)
Excellent. Thanks, Dirk!