《SQL调优和性能监控利器SQL Monitor》提到了SQL Monitor,通过v$sql_monitor视图找到对应的SQL,其中有个字段是status,
包括这些值,
- QUEUED – SQL statement is queued
- EXECUTING – SQL statement is still executing
- DONE (ERROR) – Execution terminated with an error
- DONE (FIRST N ROWS) – Execution terminated by the application before all rows were fetched
- DONE (ALL ROWS) – Execution terminated and all rows were fetched
- DONE – Execution terminated (parallel execution)
其中有个FIRST N ROWS,如果熟悉CBO优化器的朋友,可能看着眼熟,能推测出他的意思应该是“执行完成,但是仅获取前N行”。
模拟一下,执行这条语句,正常完成,
SQL> select /*+ monitor */ count(*) from test;
COUNT(*)
----------
72377
此时v$sql_monitor显示的DONE(ALL ROWS),
SQL> select username, sql_id, sql_text, status from v$sql_monitor where sql_text like '%test%' and sql_text not like '%v$sql_monitor%';
USERNAME SQL_ID SQL_TEXT STATUS
--------------- ------------- ------------------------------------------------------- -------------------
BISAL d9jb07dq0n2ny select /*+ monitor */ count(*) from test DONE (ALL ROWS)
我们尝试执行过程中ctrl+c强制中断,
SQL> select /*+ monitor */ * from test
ctrl+c,中断执行
此时看到,v$sql_monitor的status显示DONE(FIRST N ROWS),表示这条SQL只是执行了前N行,
SQL> select username, sql_id, sql_text, status from v$sql_monitor where sql_text like '%test%' and sql_text not like '%v$sql_monitor%';
USERNAME SQL_ID SQL_TEXT STATUS
--------------- ------------- ------------------------------------------------------- -------------------
BISAL aysw7ujnub4vr select /*+ monitor */ * from test DONE (FIRST N ROWS)
BISAL d9jb07dq0n2ny select /*+ monitor */ count(*) from test DONE (ALL ROWS)
因为最近在做数据相关的工作,所以对这些有点儿敏感,同样的词虽然用到了不同的功能,但是表达的含义,还是比较明确,相对比较标准,其实这些,就在潜移默化当中提升了数据质量,让系统的使用更加规范、更易理解。
声明:文中观点不代表本站立场。本文传送门:https://eyangzhen.com/136406.html