Sponsored Content
Top Forums UNIX for Advanced & Expert Users Perl-to-Oracle performance: DBI-pack visa 'sqlplus' usage Post 302371440 by adderek on Saturday 14th of November 2009 06:25:49 PM
Old 11-14-2009
Tools

Dude,

You are concerned about Oracle DB connection performance.... and it shows that you lack some basic understanding of it. I'm not a god-of-Oracle but I will try to explain some things here so that you would understand why your approach is wrong.

When you are connecting to Oracle - you are establishing a session. This would consume some memory (let say that it is 0.5 MiB) on the server. It require some time as well. Let say that it require 0.5 s. Everything you do in Oracle is done in transaction (DDL, DML, ...) and the transaction is ended by any commit (including DDL).
Whenever you make a single insert into the DB - it require some time. Let say that it is 0.0000001 s.

Now imagine that you are using sqlplus and DBI. In both cases you wish to insert a single row of data. If one of them (DBI and sqlplus) would insert data in 0.0000002 s instead of 0.0000001 s then.... which one is faster? Do you remember that the session establishment took 0.5 s?

It is possible that you would like to compare the data insertion performance. In that case I can see the following options:
1. Inserts using sql*loader in direct mode (note that additional constraints should be taken into consideration)
2. Inserts using sql*loader in indirect mode or some other thing using bulk loading (jdbc or something else)
3. Inserts using non-bulk loading (sql*loader with commit after every row or something else like repeating dumb insert n-times from perl)
4. Inserts using 1 session and 1 transaction for every row inserted into the DB

The performance is best for 1. and worst for 4.
If you wish to load a lot of data into the DB then I suggest bulk loading (JDBC might be an option) or... if you already have files like .csv then you might use sql*loader (in indirect or direct mode).

Could you, please, specify :
- What do you understand as "the performance"?
- What kind of data you would like to load?
- What Oracle version you are using?
- How many data you have? (ex. 20 000 files each 1kB or 1 file of size 1TB)
- How often the data are supposed to be loaded?
- Is the loader running on the same machine as the Oracle DB is?

Just a general hint: Thy to avoid using shell + sqlplus if you are dealing with a large number of data and complex logic.
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PERL DBI module install

We ran into an issue trying to install DBI and DB2 modules for perl for AIX from the link http://www-306.ibm.com/software/data/db2/perl/ We tried to install the DBI module using bash# perl -MCPAN -e 'install DBI' command. However we ended up with the following error. Stop. ... (3 Replies)
Discussion started by: jerardfjay
3 Replies

2. Programming

perl dbi to oracle getting disconnect_all for oracle dbi help

hi i am trying to connect to an oracle database using dbi and i get this :: Driver has not implemented the disconnect_all method. at /opt/perl/lib/site_perl/5.8.0/sun4-solaris/DBI.pm line 575 END failed--call queue aborted. for all i know, the script was working earlier, but has... (1 Reply)
Discussion started by: poggendroff
1 Replies

3. Shell Programming and Scripting

Installing Perl DBI and DBD

Hi, i have some queries on installing the Perl DBI and the DBD Oracle. I know that i have to install the DBI first. I have the source files in a folder in my home directory.The commands to install arecd /home/DBI Perl Makefile.PL make make installI would like to know, after executing these... (4 Replies)
Discussion started by: new2ss
4 Replies

4. Shell Programming and Scripting

connect to MySQL from Perl using DBI

Hi, I want to connect perl with the mysql to select and so on but the connection don't work code #!/usr/bin/perl BEGIN { # PERL MODULES WE WILL BE USING use DBI; $dbh = DBI->connect('DBI:mysql:C:\Program Files\MySQL\MySQL Server 5.0\data\db1','','pass') or die $DBI::errstr;} #... (1 Reply)
Discussion started by: eng_shimaa
1 Replies

5. UNIX for Advanced & Expert Users

Perl's DBI Module on OS X - uninstallable?

i've been struggling with installing the Perl DBI & DBD modules all weekend, and I'm getting close, but no cigar as of yet. When I run the perl script db.pl I get the following mismatch error: Mon Apr 19 09:43:29 EDT 2010 /Library/Perl/DBD-mysql-4.011 -> peterv@MBP17.local<515>$: db.pl | tee... (0 Replies)
Discussion started by: peterv6
0 Replies

6. Shell Programming and Scripting

perl: help with DBI

Hi there, I have a bit of code similar to below (which ive actually got from perldoc, but mine is similar enough) $sth = $dbh->prepare(q{ SELECT region, sales FROM sales_by_region }); $sth->execute; my ($region, $sales); # Bind Perl variables to columns: $rv =... (4 Replies)
Discussion started by: hcclnoodles
4 Replies

7. Shell Programming and Scripting

Perl DBI error

Hi All, I installed DBI module in a non INC location and using it in my script via "use lib". But it throw the below error at the "use DBI" step. Please help Usage: DBI::_install_method(dbi_class, meth_name, file, attribs=Nullsv) at /xx/xxx/xxxxx/xxxxx/oracle/lib/DBI.pm/oracle/lib/DBI.pm line... (2 Replies)
Discussion started by: prasperl
2 Replies

8. Shell Programming and Scripting

Perl Oracle DBI through Apache problem

Experts, I've been struggling with making a Perl Oracle DBI script to work through my Apache webserver. Mysql DBI scripts work fine, but I'm having issue's with Oracle. The oracle script works on command line, but I'm getting an "Internal Server Error" with apache Sourcing the oracle... (0 Replies)
Discussion started by: timj123
0 Replies
OCI_ROLLBACK(3) 														   OCI_ROLLBACK(3)

oci_rollback - Rolls back the outstanding database transaction

SYNOPSIS
bool oci_rollback (resource $connection) DESCRIPTION
Reverts all uncommitted changes for the Oracle $connection and ends the transaction. It releases all locks held. All Oracle SAVEPOINTS are erased. A transaction begins when the first SQL statement that changes data is executed with oci_execute(3) using the OCI_NO_AUTO_COMMIT flag. Further data changes made by other statements become part of the same transaction. Data changes made in a transaction are temporary until the transaction is committed or rolled back. Other users of the database will not see the changes until they are committed. When inserting or updating data, using transactions is recommended for relational data consistency and for performance reasons. PARAMETERS
o $connection - An Oracle connection identifier, returned by oci_connect(3), oci_pconnect(3) or oci_new_connect(3). RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 oci_rollback(3) example <?php // Insert into several tables, rolling back the changes if an error occurs $conn = oci_connect('hr', 'welcome', 'localhost/XE'); $stid = oci_parse($conn, "INSERT INTO mysalary (id, name) VALUES (1, 'Chris')"); // The OCI_NO_AUTO_COMMIT flag tells Oracle not to commit the INSERT immediately // Use OCI_DEFAULT as the flag for PHP <= 5.3.1. The two flags are equivalent $r = oci_execute($stid, OCI_NO_AUTO_COMMIT); if (!$r) { $e = oci_error($stid); trigger_error(htmlentities($e['message']), E_USER_ERROR); } $stid = oci_parse($conn, 'INSERT INTO myschedule (startday) VALUES (12)'); $r = oci_execute($stid, OCI_NO_AUTO_COMMIT); if (!$r) { $e = oci_error($stid); oci_rollback($conn); // rollback changes to both tables trigger_error(htmlentities($e['message']), E_USER_ERROR); } // Commit the changes to both tables $r = oci_commit($conn); if (!r) { $e = oci_error($conn); trigger_error(htmlentities($e['message']), E_USER_ERROR); } ?> Example #2 Rolling back to a SAVEPOINT example <?php $stid = oci_parse($conn, 'UPDATE mytab SET id = 1111'); oci_execute($stid, OCI_NO_AUTO_COMMIT); // Create the savepoint $stid = oci_parse($conn, 'SAVEPOINT mysavepoint'); oci_execute($stid, OCI_NO_AUTO_COMMIT); $stid = oci_parse($conn, 'UPDATE mytab SET id = 2222'); oci_execute($stid, OCI_NO_AUTO_COMMIT); // Use an explicit SQL statement to rollback to the savepoint $stid = oci_parse($conn, 'ROLLBACK TO SAVEPOINT mysavepoint'); oci_execute($stid, OCI_NO_AUTO_COMMIT); oci_commit($conn); // mytab now has id of 1111 ?> NOTES
Note Transactions are automatically rolled back when you close the connection, or when the script ends, whichever is soonest. You need to explicitly call oci_commit(3) to commit the transaction. Any call to oci_execute(3) that uses OCI_COMMIT_ON_SUCCESS mode explicitly or by default will commit any previous uncommitted transaction. Any Oracle DDL statement such as CREATE or DROP will automatically commit any uncommitted transaction. SEE ALSO
oci_commit(3), oci_execute(3). PHP Documentation Group OCI_ROLLBACK(3)
All times are GMT -4. The time now is 07:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy