oracle檢視執行最慢與查詢次數最多的sql語句

2021-08-11 14:47:16 字數 2666 閱讀 5712

**:

前言

在oracle資料庫應用調優中,乙個sql的執行次數/頻率也是常常需要關注的,因為某個sql執行太頻繁,要麼是由於應用設計有缺陷,需要在業務邏輯上做出優化處理,要麼是業務特殊性所導致。如果執行頻繁的sql,往往容易遭遇一些併發性的問題。 那麼如何檢視oracle資料庫某個sql的執行頻率/次數呢? 下面來看看完整的示例**。

一、查詢執行最慢的sql1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

select*

from(selectsa.sql_text,

sa.sql_fulltext,

sa.executions"執行次數",

round(sa.elapsed_time / 1000000, 2)"總執行時間",

round(sa.elapsed_time / 1000000 / sa.executions, 2)"平均執行時間",

sa.command_type,

sa.parsing_user_id"使用者id",

u.username"使用者名稱",

sa.hash_value

fromv$sqlarea sa

leftjoinall_users u

onsa.parsing_user_id = u.user_id

wheresa.executions > 0

orderby(sa.elapsed_time / sa.executions)desc)

whererownum <= 50;

二、查詢次數最多的 sql1

2

3

4

5

6

7

8

9

select*

from(selects.sql_text,

s.executions"執行次數",

s.parsing_user_id"使用者名稱",

rank() over(orderbyexecutionsdesc) exec_rank

fromv$sql s

leftjoinall_users u

onu.user_id = s.parsing_user_id) t

whereexec_rank <= 100;

總結

oracle 檢視執行最慢 sql

憤怒的不爭 2016 12 22 22 06 select from select sa.sql text,sa.sql fulltext,sa.executions 執行次數 round sa.elapsed time 1000000,2 總執行時間 round sa.elapsed time 1...

Oracle 通過執行計畫檢視查詢語句是否使用索引

閱讀目錄 回到頂部 explain plan for select from t call records where t bjhm 123456 備註 explain plan for後面為要生成執行計畫的查詢語句 回到頂部 如上圖所示,table access full為全表掃瞄 為t bjhm...

Oracle 執行計畫檢視

第一種 explain plan命令 plsql devoloper中的f5鍵在內部也是呼叫的此命令 用法 依次執行以下語句 explain plan for 目標sql select from table dbms xplan.display 第二種 使用dbms xplan包 1 select ...