sql vs. pl/sql: speed issue

sql vs. pl/sql: speed issue

Post by cosmin_i.. » Sun, 31 Dec 1899 09:00:00



hello all,

I am trying to do a batch update (on a single table) on perhaps 5-10%
data out of a 30 mill. rec. table and I am comparing two methods:

1)  doing a straight  update sql statement (the 'where' clause is a bit
complex) therefore a full table scan is performed;  entire operation
takes less then 5 minutes;
2)  taking the same operation under a 'cursor c ... select
rowid ....for update of ...'   pl/sql statement and then updating the
records in the body of the procedure.  This operation took around 7
minutes.

a) Does that mean that one should, if at all possible, use pl/sql only
when absolutely necessary!?
b) Is there any way to do a large sql update and commit every x records
(and not use a huge rollback segment) or is that possible only in
pl/sql!?

thanks much,

Cosmin

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

sql vs. pl/sql: speed issue

Post by michael_bia.. » Sun, 31 Dec 1899 09:00:00


Hi.

 In my experience its almost always better to use SQL instead of PL/SQL
 ( when using PL/SQL you have to pay "penalty" of context switches from
  SQL to PL/SQL and back ).

 Post yout UPDATE statement and it's EXPLAIN. It may be possible to
 avoid FULL table scan.

 HTH. Michael.



> hello all,

> I am trying to do a batch update (on a single table) on perhaps 5-10%
> data out of a 30 mill. rec. table and I am comparing two methods:

> 1)  doing a straight  update sql statement (the 'where' clause is a
bit
> complex) therefore a full table scan is performed;  entire operation
> takes less then 5 minutes;
> 2)  taking the same operation under a 'cursor c ... select
> rowid ....for update of ...'   pl/sql statement and then updating the
> records in the body of the procedure.  This operation took around 7
> minutes.

> a) Does that mean that one should, if at all possible, use pl/sql only
> when absolutely necessary!?
> b) Is there any way to do a large sql update and commit every x
records
> (and not use a huge rollback segment) or is that possible only in
> pl/sql!?

> thanks much,

> Cosmin

> Sent via Deja.com http://www.deja.com/
> Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

sql vs. pl/sql: speed issue

Post by Steve Halk » Sun, 31 Dec 1899 09:00:00


One thing which is slowing down your PL/SQL cursor is the "for update"
clause - this causes a lock to be placed on every row of the table meeting
the criteria in your WHERE clause.

> hello all,

> I am trying to do a batch update (on a single table) on perhaps 5-10%
> data out of a 30 mill. rec. table and I am comparing two methods:

> 1)  doing a straight  update sql statement (the 'where' clause is a bit
> complex) therefore a full table scan is performed;  entire operation
> takes less then 5 minutes;
> 2)  taking the same operation under a 'cursor c ... select
> rowid ....for update of ...'   pl/sql statement and then updating the
> records in the body of the procedure.  This operation took around 7
> minutes.

> a) Does that mean that one should, if at all possible, use pl/sql only
> when absolutely necessary!?
> b) Is there any way to do a large sql update and commit every x records
> (and not use a huge rollback segment) or is that possible only in
> pl/sql!?

> thanks much,

> Cosmin

> Sent via Deja.com http://www.deja.com/
> Before you buy.

 
 
 

sql vs. pl/sql: speed issue

Post by markp7.. » Sun, 31 Dec 1899 09:00:00




> One thing which is slowing down your PL/SQL cursor is the "for update"
> clause - this causes a lock to be placed on every row of the table
meeting
> the criteria in your WHERE clause.




Quote:> > hello all,

> > I am trying to do a batch update (on a single table) on perhaps 5-
10%
> > data out of a 30 mill. rec. table and I am comparing two methods:

> > 1)  doing a straight  update sql statement (the 'where' clause is a
bit
> > complex) therefore a full table scan is performed;  entire operation
> > takes less then 5 minutes;
> > 2)  taking the same operation under a 'cursor c ... select
> > rowid ....for update of ...'   pl/sql statement and then updating
the
> > records in the body of the procedure.  This operation took around 7
> > minutes.

> > a) Does that mean that one should, if at all possible, use pl/sql
only
> > when absolutely necessary!?
> > b) Is there any way to do a large sql update and commit every x
records
> > (and not use a huge rollback segment) or is that possible only in
> > pl/sql!?

> > thanks much,

> > Cosmin

I agree with Steve, the performance degration you see is due to the
fact you are selecting the data to lock it, then you are updateing it.
You are comparing apples to oranges since you changed the SQL
statement.  You should perform the same SQL from SQL*Plus and within
pl/sql to compare the times. Of course there is no real reason to use
pl/sql in a case like this since you do not need any of the extra
capabilities pl/sql provides like the ability to trap errors or perform
an if test and base you actions on the result of the test.
--
Mark D. Powell  -- The only advice that counts is the advice that
 you follow so follow your own advice --

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

1. PL/SQL vs PROC Performance Issue - Oracle 8.1.6

We have an AIX server running Oracle 8.1.6.

OS :          AIX 4.3.3 (64 bit)
Oracle:     8.1.6.2.0
# CPU's:   12      (450 MHz processors)
Memory:   40 GB  (RAM)
Oracle:      8.1.6.2.0

PL / SQL script   does an UPDATE/COMMIT of 10,000 records in 2 Secs.
PROC  program  doing the exact same UPDATE/COMMIT  of 10,000 records takes
100 secs.

Question:   Why  is  PROC 50 times slower than PL/SQL ?

On our Developer workstations,   the  PL/SQL to PROC performance ration is
about 2-3.

Need  help from the Oracle Gurus out there to identify the bottleneck w.r.t.
PROC program.
System was 99% idle and these tests were run in stand alone mode.

Rath

2. mkded&linux

3. Access speed Vs MS Sql Speed

4. Full text queries

5. PL/SQL:Efficiency of inline SQL vs use of Dynamic SQL Package

6. Logfiles Directory Reallocation???

7. SQL vs VB SQL Query Speed?

8. Paradox 8 can't open Paradox 5 files. What gives.

9. Speed comparison, MS SQL vs Sybase SQL for Netware

10. SQL-92, Migrate PL/SQL at ORACLE into PL/SQL at SQL Server 7.0

11. Embedded SQL vs. PL/SQL (DB2 Embedded SQL vs. Oracle PL/SQL)