oracle 获取查询的运行时执行计划

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14480264/
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 01:23:54  来源:igfitidea点击:

get runtime execution plan of a query

oracleoracle11g

提问by michael nesterenko

I have an application that executes some sql queries. How can I get execution plan for currently executing query from sqlplus or some other oracle client? I can amend oracle session that is used in application, if that is necessary.

我有一个执行一些 sql 查询的应用程序。如何从 sqlplus 或其他一些 oracle 客户端获取当前正在执行的查询的执行计划?如果有必要,我可以修改应用程序中使用的 oracle 会话。

I do not want to use explain planand execute that query by hand, I need to get actual execution plan that is used for query.

我不想explain plan手动使用和执行该查询,我需要获取用于查询的实际执行计划。

回答by OldProgrammer

You can run explain plain on historical queries from the SGA -examples

您可以对来自 SGA 的历史查询运行解释普通 -示例

And listing B.

并列出 B。

Example:

例子:

SELECT username, prev_sql_id
FROM v$session
WHERE username = 'RDEVALL'  -- example user

SQL ID returned

返回的 SQL ID

RDEVALL a1d4z5ruduzrd
RDEVALL avmbutuknvb6j
RDEVALL 75g0tqd9x743y
RDEVALL 5fnkh6c8mqqt3
RDEVALL 75g0tqd9x743y

Pick query ID and use here:

选择查询 ID 并在此处使用:

SELECT *
  FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR('a1d4z5ruduzrd')); -- replace with sql ID as needed