|
Posted by ZeldorBlat on 12/20/05 06:01
Susan Baker wrote:
> Does PHP (or maybe the web server - Apache in my case), support
> (database) connection pooling?. It seems terribly inefficient if every
> request for data wil incurr the overhead of creating a connection to the
> db.
>
Sure. Look at the pconnect() family of functions. The exact function
will depend on the database system you're connecting to. For MySQL
it's mysql_pconnect().
pconnect() will leave the connection open when done and reuse idle
connections if available. Be careful, though -- I've seen some weird
problems with connections not being properly closed, especially when a
query blocks.
Although it may seem inefficient to open a new database connection each
time, I'd try both ways (connect() and pconnect()) and see if you
really notice a difference. If you don't, it's probably worth sticking
to plain old connect().
Navigation:
[Reply to this message]
|