oracle 检查状态 sql 查询或百分比

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9005798/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 00:33:50  来源:igfitidea点击:

Check status sql query or percentage

sqloracleoracle-sqldeveloper

提问by Eve

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

我正在运行一项工作,但这项工作需要很长时间,所以我想检查从查询中执行了多少 %。我在 Oracle sqldeveloper 中运行查询

采纳答案by N West

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 Tomfor more info.

由于 SQL 和数据库处理的基于集合的特性,您无法真正获得查询的“完成百分比”,因为 oracle 引擎并不确定。您可以尝试查看视图 v$session_longops 以查看 SQL 的各个部分已经走了多远(大型哈希联接或全表扫描可能会显示在此处)。看看这个 Ask Tom了解更多信息。

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.

如果您的作业有多个 SQL 语句,并且您试图跟踪每个 SQL 语句之后的进度,您可以添加一些代码以在每个语句之后在控制表上插入状态更新。

回答by Superdooperhero

The output_rowscolumn 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.

output_rows如果您的查询是不是在这个查询列可能是有用的v$session_longops。问题是您不知道总输出行数是多少。

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

回答by Rajesh Singam

You can check gv$session_longops where time_remaining>0;

你可以检查 gv$session_longops where time_remaining>0;

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

从 gv$session_longops 中选择 sid,target_desc,(Sofar*100)/totalwork as percent_complete

would give you the percentage.

会给你百分比。