If you use perl with oracle 11g databases, you should consider using database resident connection pooling to reduce the overheads associated with connecting and disconnecting from oracle. Much has been written about how Php applications benefit by using database resident connection pooling (Because Php does not have a connection pooling mechanism of its own, unlike Java). Similar benefits can be derived by Perl Applications Too.
Mostly perl 5 applications will be using DBI and DBD – Oracle to interact with oracle databases. Since DBD – Oracle uses OCI to communicate with the oracle database, it can benefit by using database resident connection pooling.
When the database is configured for database resident connection pooling, the oracle database creates and maintains a pool of database connections. These connections are then shared by applications connecting to the oracle database. The advantage of this is that the connections are already created, so you do not incur the overhead of establishing a brand new connection to the database. You are just reusing an existing one. This is especially helpful if you have an application that establishes connections and disconnects from the oracle database very rapidly/frequently.
A connection pool can be configured and started in the database as follows
SQL> execute dbms_connection_pool.configure_pool(null,minsize=>2,maxsize=>4);
SQL> execute dbms_connection_pool.start_pool;
A connect string can be configured in the tnsnames.ora to connect to this connection pool using the following syntax
(ADDRESS = (PROTOCOL = TCP)(HOST = rramdas-us)(PORT = 1521))
(SERVER = POOLED)
(SERVICE_NAME = RK01)
The perl program can then establish the connection to the database using this connect string in tnsnames.ora
my $dbh = DBI->connect( ‘dbi:Oracle:RK01POOL‘,
) || die “Database connection not made: $DBI::errstr”;
Thats all it takes, and now you can reap the benefits of using oracle database resident connection pooling with Perl.
You can use dbms_connection_pool.stop_pool to stop the connection pool in the database.
You can use the data dictionary views dba_cpool_info, and dynamic views v$cpool_cc_info, v$cpool_cc_stats, v$cpool_stats to monitor database resident connection pools.