Welcome Guest ( Log In | Register )


 
 
 
 

Oracle performance tuning book

 

 
Oracle performance tuning 

software
 
Oracle 

performance Tuning 10g reference poster
 
Oracle training in Linux 

commands
 
Oracle training 

Excel
 
Easy Oracle Jumpstart
 
Oracle training & performance tuning books
 
Burleson Consulting Remote DB Administration
 
 
2 Pages V   1 2 >  
Reply to this topicStart new topic
> Insert with a select, Insert with a select
avdba_22
post Aug 29 2005, 12:27 PM
Post #1


Advanced Member
***

Group: Members
Posts: 110
Joined: 25-February 05
Member No.: 1,517



We are using 10g. I have to load about 15million records or more from staging table into another table. It is a OLTP environment. And it is taking about 1 hrs to do this.

I am doing :

insert into t_so(SO_ID,
FIRST_NAME,
LAST_NAME,
ADDRESS1,
ADDRESS2,
MIDDLE_INITIAL,
CITY_STATE_ZIP_ID)
SELECT seq_So.nextval,
PCFIRST,
PCLAST,
substr(PCMINIT, 1,1) PCMINIT,
PCPADDR,
PCSADDR,
pkg_so.fn_get_city_state_zip_id ( PCCITY , PCSTATE, PCZIP5)
FROM t_stage;

I optimized the function and there is lot of improvement . Could any of you suggest anything more I could do to improve performance in 10g. Please let me know .

Thanks
Go to the top of the page
 
+Quote Post
edwardstoever
post Aug 29 2005, 01:19 PM
Post #2


Advanced Member
***

Group: Members
Posts: 554
Joined: 29-October 04
From: California
Member No.: 923



Optimization is a funny thing. Sometimes we spend hours to "optimize" something to save time. So, we get it to work faster, say we cut it from 2 hours down to 1 hour. But it takes us 3 hours to "fix" it, and it will only be run twice, then never again.

So, we trade our own time for server time.

I would rather drink coffee than worry about that kind of thing.

It really comes down to this: how often are you going to insert 15 million rows? Just one time? Lots of times? Every day for the next 10 years?

Does it really have to go faster?

Thanks,

Edward
Go to the top of the page
 
+Quote Post
hpuxrac3
post Aug 29 2005, 03:22 PM
Post #3


Advanced Member
***

Group: Members
Posts: 32
Joined: 25-August 05
Member No.: 2,808



The scientific way to approach this is to determine what is slowing down the load time. This is known as the wait event interface approach.

I would guess ... without knowing anything for sure ... that your call that invokes the plsql function is what is slowing down the load.

So without real evidence I would guess that eliminating the calsl to the plsql function would help you out.

Puttting on a 10046 trace and performing your analysis of what shows up as slowing down the load is the most reliable approach. That way you ( and I ) are not guessing.

If the results of a 10046 trace show mostly CPU then that would to me appear to confirm that the plsql function is part of your bottleneck.
Go to the top of the page
 
+Quote Post
avdba_22
post Aug 29 2005, 04:04 PM
Post #4


Advanced Member
***

Group: Members
Posts: 110
Joined: 25-February 05
Member No.: 1,517



We will using this insert many many times. Function had a problem and that is fixed. In addition can some one give me some tips on how to improve such inserts?

for ex) using append hint .. looking for this kind of other tips in 10g.

Thank you.
Go to the top of the page
 
+Quote Post
dave
post Aug 30 2005, 03:01 AM
Post #5


Advanced Member
***

Group: Members
Posts: 4,843
Joined: 8-October 04
Member No.: 785



if not using the table while inserting

try dropping the indexes insert /*+append*/ then rebuild the indexes nologging (then take a backup!)
Go to the top of the page
 
+Quote Post
mike9
post Sep 1 2005, 03:51 AM
Post #6


Newbie
*

Group: Members
Posts: 7
Joined: 23-August 05
Member No.: 2,785



I would try to remove the function and to replace it with a join with a table containing (PCCITY , PCSTATE, PCZIP5, state_zip_id).

For large inserts I would recommand to set the CACHE of you sequence to something like 100.


--------------------
[img]http://www.eff.org/br/br.gif[/img]
Go to the top of the page
 
+Quote Post
burleson
post Sep 1 2005, 06:26 AM
Post #7


Advanced Member
***

Group: Members
Posts: 7,063
Joined: 26-January 04
Member No.: 13



smile.gif

Hi,

Here are some general tips from Davce Moore's book "Oracle Utilities"

http://www.dba-oracle.com/oracle_tips_load_speed.htm

- Edited to remove potential errors -


--------------------
Hope this helps. . .

Donald K. Burleson
Oracle Press author
Author of Oracle Tuning: The Definitive Reference
Go to the top of the page
 
+Quote Post
mbobak
post Sep 1 2005, 05:49 PM
Post #8


Advanced Member
***

Group: Members
Posts: 547
Joined: 25-May 05
From: Belleville, MI
Member No.: 2,186



Couple of quick points:
Regarding "a" in Don's first post in this thread, using parallel programs and each using APPEND
will not work. APPEND takes an exclusive TM enqueue. This will cause the other parallel processes
to serialize, and you won't gain any benefit. If you want to comine parallel processing and the
APPEND hint, use Oracle's parallel DML. (See the PARALLEL hint).

Also, if you're going w/ APPEND, consider putting the table into NOLOGGING mode, which will
allow Oracle to avoid almost all redo logging. (I assume the database is in archive log mode.
In noarchivelog mode, the redo is automatically avoided when using APPEND, and the NOLOGGING
setting is not needed.) If you are considering NOLOGGING, consider the backup and recovery
implications before proceeding.

Hope that helps,

-Mark


--------------------
--
Mark J Bobak
mark@bobak.net

Do you want good, clear answers to your questions?
Read THIS BEFORE posting!
Go to the top of the page
 
+Quote Post
Laks
post Sep 1 2005, 09:37 PM
Post #9


Advanced Member
***

Group: Members
Posts: 154
Joined: 31-July 05
Member No.: 2,629



Hi Mark,
As of Oracle 9i i think parallel DML would work only on partitioned tables and it would be really beneficial if the table is partitioned else created a CPU bottleneck..
But not sure of how parallel DML works in 10G?
Can you Please clarify here?

Thanks
Laks


--------------------
Go to the top of the page
 
+Quote Post
mike9
post Sep 2 2005, 04:20 AM
Post #10


Newbie
*

Group: Members
Posts: 7
Joined: 23-August 05
Member No.: 2,785



How long does it take to execute the following 2 inserts?

insert /*+ append */ into t_so(SO_ID,
FIRST_NAME,
LAST_NAME,
ADDRESS1,
ADDRESS2,
MIDDLE_INITIAL,
CITY_STATE_ZIP_ID)
SELECT seq_So.nextval,
PCFIRST,
PCLAST,
substr(PCMINIT, 1,1) PCMINIT,
PCPADDR,
PCSADDR,
pkg_so.fn_get_city_state_zip_id ( PCCITY , PCSTATE, PCZIP5)
FROM t_stage;


insert /*+ append */ into t_so(SO_ID,
FIRST_NAME,
LAST_NAME,
ADDRESS1,
ADDRESS2,
MIDDLE_INITIAL,
CITY_STATE_ZIP_ID)
SELECT seq_So.nextval,
PCFIRST,
PCLAST,
substr(PCMINIT, 1,1) PCMINIT,
PCPADDR,
PCSADDR,
1
FROM t_stage;


--------------------
[img]http://www.eff.org/br/br.gif[/img]
Go to the top of the page
 
+Quote Post
mbobak
post Sep 2 2005, 07:49 AM
Post #11


Advanced Member
***

Group: Members
Posts: 547
Joined: 25-May 05
From: Belleville, MI
Member No.: 2,186



Hmm...actually, parallel DELETE and UPDATE don't work on non-partitioned tables.
Parallel INSERT is ok. However, there are other restrictions. No referential integrity, for
example.

See: http://download-west.oracle.com/docs/cd/B1...ns.htm#CNCPT328

for more info.


--------------------
--
Mark J Bobak
mark@bobak.net

Do you want good, clear answers to your questions?
Read THIS BEFORE posting!
Go to the top of the page
 
+Quote Post
burleson
post Sep 2 2005, 07:55 AM
Post #12


Advanced Member
***

Group: Members
Posts: 7,063
Joined: 26-January 04
Member No.: 13



smile.gif

Hi,

Question for Mark,

You noted:

QUOTE
using parallel programs and each using APPEND will not work. APPEND takes an exclusive TM enqueue. This will cause the other parallel processes
to serialize, and you won't gain any benefit.


Thanks! I have updated my notes.

It was my undersanding that APPEND will increase the HWM on each freelist independently, and the TM enqueue would only happen if you forgot to define multiple freelists for the table/indexes.

- Does this "APPEND" TM serialization apply when using multiple freelists or freelist groups?

- What about Automatic Segment Space Management (bitmap freelists)? The documentation implies that there will not be serialization for free space lookups.

Can you educate us, please? TIA!


--------------------
Hope this helps. . .

Donald K. Burleson
Oracle Press author
Author of Oracle Tuning: The Definitive Reference
Go to the top of the page
 
+Quote Post
mbobak
post Sep 2 2005, 09:27 AM
Post #13


Advanced Member
***

Group: Members
Posts: 547
Joined: 25-May 05
From: Belleville, MI
Member No.: 2,186



Hi Don,

Blocks which have been allocated to a segment can be in one of three situations:

- Above the HWM. They have never been used, or at least, not been used since the
segment was last truncated or moved.

- Below the HWM, on a free list. These are blocks which have (or recently had) some
data in them, but based on PCTFREE/PCTUSED settings, have space still available. These blocks
will be used for conventional (non-direct) inserts.

- Below the HWM, not on a freelist. These are blocks which have data in them, and based
on PCTFREE/PCTUSED settings, do not have enough space available to support other inserts.

Now, when you do a direct-path INSERT, it will allocate blocks *above* the HWM. Therefore,
none of those blocks are on a free list. The free list(s) is (are) out of the picture. So, it really
doesn't matter how many free lists you have. In the direct-path INSERT case, free lists do not
play a role.

As to the TM enqueue, well, any DML or DDL will take a TM enqueue. This is to protect the
object's data dictionary definition. Conventional DML will take a TM enqueue in shared mode.
DDL takes a TM enqueue in exclusive mode. So, a table that's undergoing DML cannot have
DDL executed. (The exclusive mode required for DDL is not compatible with the shared mode
the DML session already holds.) However, other conventional DML will be able to proceed,
cause a shared mode enqueue is comatible with the shared mode already held. In this way,
Oracle allows concurrent DML, while preventing DDL on tables undergoing DML. Now, the direct-
path INSERT is a special case. A direct-path INSERT takes a TM enqueue in exclusive mode,
the same as DDL does. This prevents all other DML from occurring. Honestly, I don't know
enough about the details of the mechanism to clearly explain why this is required. I would
speculate it's because otherwise, it would be possible to have direct-path INSERT modifying
the HWM, and then (if it were permitted) conventional DML could fill all the blocks on the freelists,
causing that session to want to raise the HWM. That would be a problem, cause you'd have two
different sessions wanting to raise the HWM at the same time. So, seems to me, you either
serialize on the TM enqueue, or, you'd serialize on ST enqueue. (ST=space management
transaction enqueue)

As to ASSM, I really don't have much experience w/ that feature yet, however, from the
point of view of why a direct-path INSERT requires an exclusive TM enqueue, I think the
argument is largely the same. you don't want to concurrent DML sessions trying to concurrently
access the HWM.

Hope that's clear and answers your questions,

-Mark


--------------------
--
Mark J Bobak
mark@bobak.net

Do you want good, clear answers to your questions?
Read THIS BEFORE posting!
Go to the top of the page
 
+Quote Post
mbobak
post Sep 2 2005, 09:29 AM
Post #14


Advanced Member
***

Group: Members
Posts: 547
Joined: 25-May 05
From: Belleville, MI
Member No.: 2,186



Whoops, David beat me to it....;-)


--------------------
--
Mark J Bobak
mark@bobak.net

Do you want good, clear answers to your questions?
Read THIS BEFORE posting!
Go to the top of the page
 
+Quote Post
mbobak
post Sep 2 2005, 01:51 PM
Post #15


Advanced Member
***

Group: Members
Posts: 547
Joined: 25-May 05
From: Belleville, MI
Member No.: 2,186



Oh, by the way, Don, in point 'c' in that tip, the example insert statement you give:
CODE
insert /*+ append */ into customer values ('hello',';there');


is not valid. APPEND only works with Insert into table1 select * from table2;

It really doesn't make sense for a single-row insert.

-Mark


--------------------
--
Mark J Bobak
mark@bobak.net

Do you want good, clear answers to your questions?
Read THIS BEFORE posting!
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 8th February 2010 - 06:32 PM