Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check status sql query or percentage

Does anyone know if there is a way to check the status of a job currently running in the database or the status of how many % has actually been executed.

I am running a job but the job is taking a long time so I would like to check how many % has been executed from the query. I am running the query in Oracle sqldeveloper

like image 339
Eve Avatar asked Jan 25 '12 16:01

Eve


People also ask

How do I show percentage in SQL query?

There is no built-in operator that calculates percentages in SQL Server. You have to rely on basic arithmetic operations i.e. (number1/number2 x 100) to find percentages in SQL Server.

How do you check the progress of a query in SQL Server?

You can view this by Right Clicking on Instance Name in SQL Server Management Studio and selecting “Activity Monitor”. Activity monitor tells you what the current and recent activities are in your SQL Server Instance. The above screenshot displays an overview window for the Activity Monitor.

What percentage means SQL?

The SQL LIKE Operator There are two wildcards often used in conjunction with the LIKE operator: The percent sign (%) represents zero, one, or multiple characters. The underscore sign (_) represents one, single character.

How do I see query results in SQL Developer?

You can toggle a setting to "Show query results in new tabs" under Tools -> Preferences... -> Database -> Worksheet, so if you have all queries highlighted and Click F9 (Run), then each query result appears in a new grid tab.


3 Answers

Due to the set-based nature of SQL and database processing, you can't really get a "% complete" of a query since the oracle engine doesn't really know for sure. You could try looking at the view v$session_longops to see how far along parts of your SQL has gone (a large hash join or full table scan may show up here). Take a look at this Ask Tom for more info.

If your job has multiple SQL statements and you're trying to track how far along you are after each one, you could add some code to insert status updates on a control table after each statement.

like image 56
N West Avatar answered Sep 28 '22 07:09

N West


The output_rows column in this query might be useful if your query is not in v$session_longops. The problem is you don't know what the total output rows is.

select plan_operation, plan_options, plan_object_name, plan_object_type, plan_bytes, plan_time, plan_cpu_cost, plan_io_cost, output_rows, workarea_mem
from   v$sql_plan_monitor
where  sid = 2646
and    status = 'EXECUTING'
order  by plan_line_id
like image 27
Superdooperhero Avatar answered Sep 28 '22 07:09

Superdooperhero


You can check gv$session_longops where time_remaining>0;

select sid,target_desc,(Sofar*100)/totalwork as percentage_complete from gv$session_longops

would give you the percentage.

like image 23
Rajesh Singam Avatar answered Sep 28 '22 09:09

Rajesh Singam