oracle 查询最近执行过的 SQL语句 (2014-06-09 18:02:43) 转载▼ 分类: Database oracle 查询最近执行过的 SQL语句 select sql_text,last_load_time from v$sql order by last_load_time desc; SELECT sql_text, last_load_time FROM v$sql WHERE last_load_time IS NOT NULL and sql_text…
oracle 查询最近执行过的 SQL语句 select sql_text,last_load_time from v$sql order by last_load_time desc; SELECT sql_text, last_load_time FROM v$sql WHERE last_load_time IS NOT NULL and sql_text like 'select%' ORDER BY last_load_time DESC; SELECT sql_tex…
oracle 查询最近执行过的 SQL语句 select sql_text,last_load_time from v$sql order by last_load_time desc; SELECT sql_text, last_load_time FROM v$sql WHERE last_load_time IS NOT NULL and sql_text like 'select%' ORDER BY last_load_time DESC; SELECT sql_text, l…
SELECT b.sql_text, --content of SQL a.machine, --which machine run this code a.username, a.module, -- the method to run this SQL c.sofar / totalwork * 100, --conplete percent c.elapsed_seconds, --run time c.time_remaining --remain to run time FROM v$…
在SQL优化过程,有时候需要查看哪些SQL具有多个执行计划(Multiple Executions Plans for the same SQL statement),因为同一个SQL有多个执行计划一般意味着代码有问题或某些其它原因,例如,SQL语句使用绑定变量,但是绑定变量的类型或长度可能不一致会导致同一SQL出现不同执行计划. --查看数据库里面有多个执行计划的SQL语句的SQL_ID SELECT SQL_ID, COUNT(1) AS PLAN_NUM FROM V$SQL GROUP …
SELECT TOP 10 TEXT AS 'SQL Statement' ,last_execution_time AS 'Last Execution Time' ,(total_logical_reads + total_physical_reads + total_logical_writes) / execution_count AS [Average IO] ,(total_worker_time / execution_count) / 1000000.0 AS [Average…
当需要分析执行过的SQL语句来判断问题,可以通过打开查询日志功能,但是重启MySQL服务后需要重新配置. 查询日志查询功能: SHOW VARIABLES LIKE 'general%'; general_log:日志功能是否开启,默认关闭OFF general_log_file:日志文件保存位置 开启日志: set GLOBAL general_log='ON'; 查询是否开启: SHOW VARIABLES LIKE 'general_log';…