GTT helps performance - one day to be several minute

I have a a case like this:
for rec (select *
from gl.interface
where accounting_date between...
order by c1, c2)
loop
   -- concate some columns of rec
   -- do update gl_interface
end loop;it takes about a day to generate notepad report from this query (the records is about 6.000.000).
And after along day, i resolve it and it takes only several minutes to generate the report.
What i am doing is these steps:
1. create global temporary table that delete records after commit. And create some indeks, like rn that is row_number() over (order by c1, c2)
2. ITAS the gtt with select * , row_number() over (order by c1, c2)
from gl.interface
where accounting_date between
3. change the cursor query above in my oracle form:
for rec in(
   select *
from gtt
where accounting_date between...
order by rn
loop
end loop;
update gl_interface
set...
where exists(
  select ..
from gtt...
where col1 =...
)I still wonder how it works? and what is the drawbacks of using this gtt? tx.
Edited by: infotools on Jan 7, 2013 3:35 AM
Edited by: infotools on Jan 7, 2013 3:35 AM
Edited by: infotools on Jan 7, 2013 3:36 AM

infotools wrote:
No, i don't want to use bulk for i don't want to create arrays. And for my case, i am satisfied with the results. But, i still wonder how it decrease the time so much using gtt...and can be ITAS...and may be the
select a||b||c
from
instead of
for ()
loop
s = cc.a || cc.b||cc.c....
end loop;
is it because i put much of the pl-sql statements in my select-sql?Likely because you have reduced context switching between the SQL and PL/SQL engines. By selecting rows in a loop and updating or inserting for each row selected, you are constantly switching back and forth between PL/SQL and SQL, and that is known to be poor for performance. Using a GTT will help improve things because you are reducing the amount of context switches, but then if the data is already coming from database tables, you shouldn't need to use a GTT in the first place... as just doing it directly from the database tables, using something like MERGE will do it all in the SQL engine anyway.

Similar Messages

Maybe you are looking for

  • Closing Reports Background Engine from VB

    I have a Visual Basic 6 application that runs Reports 6 reports with the ActiveX control Rwsxa60.ocx. When you close the application, the Reports background engine is still open. Is there a way to close the engine through VB? Thanks in advance for an

  • Open OA Page in new Tab or new Window

    Hi I there a way that you can set a page to open up in a new tab or window instead of replacing the current page you are in? thank you

  • Patch for JSF1.0

    Does anyone know if Sun has any plans to release a patch for the current RI?

  • Can't get itunes to play on my computer

    I have Window 8.1 and just did an update in itunes but when I went to play my songs they won't play.

  • AirPort fully Connected but Safari not loading

    My airport shows i'm picking up full bars from my wireless router. But when i run safari it shows that i'm not connected to the server. I have a magicjack connected to my macbook and thats running fine.. fyi internet is needed to run this. Also on my