I am using PHP with Oracle Database 12c and i want to implement connection pooling for improve my application performance Can you help me please ?
-
What you have tried so far?Hassaan– Hassaan2020-05-21 09:29:22 +00:00Commented May 21, 2020 at 9:29
-
well, i tried this example workwiththebest.intraway.com/blog-post/…, but it's showing TNS error only when i put this :POOLED string after service nameJafor Iqbal– Jafor Iqbal2020-05-21 10:16:29 +00:00Commented May 21, 2020 at 10:16
1 Answer
Check the Database Resident Connection Pooling (DRCP) chapter of Oracle's free The Underground PHP and Oracle Manual.
First determine if you need DRCP. I assume you are already using persistent oci_pconnect() calls, which is the first thing to do to improve connection performance.
Like any pool, DRCP is a shared resource so there is some overhead and you need to make sure that connections are not held open which would block other users. If you're not running out of memory on the DB server host, I would suggest not using it.
If you decide to try it, the basic steps are:
- start the pool, something like
SQL> execute dbms_connection_pool.start_pool() - update your php.ini and set a connection class:
oci8.connection_class = MYPHPAPP - Use a pooled connect string like
or$c = oci_pconnect('myuser', 'mypassword', 'myhost/sales:POOLED');
where the connect alias is in a tnsnames.ora file:$c = oci_pconnect('myuser', 'mypassword', 'salespool');salespool=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=myhost.dom.com) (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=sales) (SERVER=POOLED)))