Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check progress of long running insertions in oracle

I am trying to insert 1 million record after performing some calculation on each row in oracle. 15 hours gone and it is still in works. When i write a select query on this table it shows nothing. I don't know where is my inserted data going on each insert.

So my question is that, is there any way to check how many rows insert till now while performing long running insertion in oracle table, thanks.

like image 941
user3004110 Avatar asked Jan 07 '15 10:01

user3004110


People also ask

How can I speed up insert in Oracle?

One of the most common ways to improve the performance of an INSERT operation is to use the APPEND optimizer hint. APPEND forces the optimizer to perform a direct path INSERT and appends new values above the high water mark (the end of the table) while new blocks are being allocated.

Can we use datediff in Oracle?

Use the @DATEDIFF function to calculate the difference between two dates or datetimes, in days or seconds. The difference between the specified dates. Valid values can be: DD , which computes the difference in days.

Should I commit after every insert?

For a conventional INSERT , you probably only want to commit when the application's logical transaction is complete. Unnecessarily committing after every conventional insert would cause problems with performance and atomicity. For a direct-path INSERT /*+ APPEND */ , you probably need to commit as soon as possible.


1 Answers

It depends whether you are doing the insertion in SQL or PL/SQL. While using PL/SQL you have your own ways to get the number of rows already been processed, you can of course write your own program.

Coming to SQL, I can think of two ways :

  • V$SESSION_LONGOPS
  • V$TRANSACTION

Most of the GUI based tools would have nice graphical representation for the long operations view. You can query -

SELECT ROUND(SOFAR*21411/TOTALWORK)
FROM V$SESSION_LONGOPS
WHERE username     = '<username>'
AND TIME_REMAINING > 0

The V$TRANSACTION view can tell you whether any transaction is still pending. If your INSERT is completed and COMMIT is issued, the transaction would be completed. You can join it with v$session. You can query -

SELECT     .... 
from       v$transaction t 
inner join v$session s 
ON         t.addr = s.taddr;
like image 141
Lalit Kumar B Avatar answered Oct 24 '22 16:10

Lalit Kumar B