Welcome Guest, Not a member yet? Register   Sign In
Simple Database Connect Question
#1

[eluser]tokyotoejam[/eluser]
Ok. I am building a social network site which is almost in beta. The profile page for example runs queries to grab comments, blogs, top friends, profile pic, etc. Thats several good queries for just one page.

I have DB connecting automatically in config.

So here is the question.
Does the db connect only once per start of page, run all queries, and then close once page is processed OR does the DB connect each time I do a $this->db-get(),insert,yada yada and close at the end of each method call resulting in 5 or 6 connections per page?

What is the recommended way of doing this per page, so that if the website get hit BIG time it will handle it?
#2

[eluser]jcopling[/eluser]
This would be directly related to the 'pconnect' setting inside the database config file.

Depending on which database you use, having 'pconnect' set to true should retain a persistent connection throughout.

I say depending on which db you use because I have read that MSSQL databases do not behave correctly with a persistent connection.
#3

[eluser]tokyotoejam[/eluser]
I am using good ol MySQL.
#4

[eluser]tokyotoejam[/eluser]
So can anyone answer if CI reconnects for each $this->db->get ??? or once per page???
#5

[eluser]tonanbarbarian[/eluser]
As far as I am aware CI connects once per page only
persistent connections allow PHP to use a pool of connections that have been used by previous page requests thereby saving connection time
#6

[eluser]tokyotoejam[/eluser]
Thanks tonan, that clarifies things for me. I was hoping that it only connected once per page Smile




Theme © iAndrew 2016 - Forum software by © MyBB