Oracle查看SQL执行计划的方式

 

  获取Oracle sql执行计划并查看执行计划,是掌握和判断数据库性能的基本技巧。下面案例介绍了多种查看sql执行计划的方式:

 

基本有以下几种方式:

1、通过sql_trace初始化参数

2、通过Autotrace

3、通过explain plan

4、通过dbms_xplan.display_cursor

5、通过dbms_xplan.display_awr

6、通过10046事件

1、通过explain plan 工具

12:24:00 SCOTT@ prod>explain plan for

12:24:06   2  select empno,ename,sal,deptno from emp where empno=7788;

Explained.

Elapsed: 00:00:00.22

12:24:16 SCOTT@ prod>select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT

------------------------------------------------------------------------------------------------------

Plan hash value: 2949544139

--------------------------------------------------------------------------------------

| Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |

--------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT            |        |     1 |    46 |     2   (0)| 00:00:01 |

|   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    46 |     2   (0)| 00:00:01 |

|*  2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     1   (0)| 00:00:01 |

--------------------------------------------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

2 - access("EMPNO"=7788)

14 rows selected.

Elapsed: 00:00:01.14

2、通过DBMS_XPLAN.display_cursor查看

12:52:37 SCOTT@ prod>desc dbms_xplan

FUNCTION DISPLAY_CURSOR RETURNS DBMS_XPLAN_TYPE_TABLE

Argument Name                  Type                    In/Out Default?

------------------------------ ----------------------- ------ --------

SQL_ID                         VARCHAR2                IN     DEFAULT

CURSOR_CHILD_NO                NUMBER(38)              IN     DEFAULT

FORMAT                         VARCHAR2                IN     DEFAULT

如果以scott用户访问需要进行授权:

12:31:44 SYS@ prod>select * from dict where upper(table_name)='V$SESSION';

TABLE_NAME                     COMMENTS

------------------------------ ----------------------------------------

V$SESSION                      Synonym for V_$SESSION

Elapsed: 00:00:00.09

12:31:09 SYS@ prod>grant select on V_$SESSION to scott;

Grant succeeded.

Elapsed: 00:00:00.10

12:43:15 SCOTT@ prod>select * from table(dbms_xplan.display_cursor(null,null,'advanced'));

PLAN_TABLE_OUTPUT

------------------------------------------------------------------------------------------------------

User has no SELECT privilege on V$SQL_PLAN

解决权限不足:

12:42:33 SYS@ prod>grant select any table to scott;

Grant succeeded.

12:43:46 SYS@ prod>show parameter o7

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

O7_DICTIONARY_ACCESSIBILITY          boolean     TRUE

12:44:54 SYS@ prod>

案例:dbms_xplan.display_cursor

12:42:45 SCOTT@ prod>select empno,ename,sal,deptno from emp where empno=7788;

EMPNO ENAME             SAL     DEPTNO

---------- ---------- ---------- ----------

7788 SCOTT            3000         20

Elapsed: 00:00:00.08

12:43:15 SCOTT@ prod>select * from table(dbms_xplan.display_cursor(null,null,'all'));

PLAN_TABLE_OUTPUT

------------------------------------------------------------------------------------------------------

SQL_ID  bqz9ujgnn4jzu, child number 0

-------------------------------------

select empno,ename,sal,deptno from emp where empno=7788

Plan hash value: 2949544139

--------------------------------------------------------------------------------------

| Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |

--------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT            |        |       |       |     2 (100)|          |

|   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    46 |     2   (0)| 00:00:01 |

|*  2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     1   (0)| 00:00:01 |

--------------------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):

-------------------------------------------------------------

PLAN_TABLE_OUTPUT

------------------------------------------------------------------------------------------------------

1 - SEL$1 / EMP@SEL$1

2 - SEL$1 / EMP@SEL$1

Predicate Information (identified by operation id):

---------------------------------------------------

2 - access("EMPNO"=7788)

Column Projection Information (identified by operation id):

-----------------------------------------------------------

1 - "EMPNO"[NUMBER,22], "ENAME"[VARCHAR2,10], "SAL"[NUMBER,22],

"DEPTNO"[NUMBER,22]

2 - "EMP".ROWID[ROWID,10], "EMPNO"[NUMBER,22]

32 rows selected.

Elapsed: 00:00:00.05

案例:

12:49:10 SCOTT@ prod>select empno,ename,sal,deptno from emp where empno=7788;

EMPNO ENAME             SAL     DEPTNO

---------- ---------- ---------- ----------

7788 SCOTT            3000         20

Elapsed: 00:00:00.00

12:50:06 SCOTT@ prod>select * from table(dbms_xplan.display_cursor(null,null,'advanced'));

PLAN_TABLE_OUTPUT

------------------------------------------------------------------------------------------------------

SQL_ID  bqz9ujgnn4jzu, child number 0

-------------------------------------

select empno,ename,sal,deptno from emp where empno=7788

Plan hash value: 2949544139

--------------------------------------------------------------------------------------

| Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |

--------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT            |        |       |       |     2 (100)|          |

|   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    46 |     2   (0)| 00:00:01 |

|*  2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     1   (0)| 00:00:01 |

--------------------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):

-------------------------------------------------------------

PLAN_TABLE_OUTPUT

------------------------------------------------------------------------------------------------------

1 - SEL$1 / EMP@SEL$1

2 - SEL$1 / EMP@SEL$1

Outline Data

-------------

/*+

BEGIN_OUTLINE_DATA

IGNORE_OPTIM_EMBEDDED_HINTS

OPTIMIZER_FEATURES_ENABLE('11.2.0.1')

DB_VERSION('11.2.0.1')

ALL_ROWS

OUTLINE_LEAF(@"SEL$1")

INDEX_RS_ASC(@"SEL$1" "EMP"@"SEL$1" ("EMP"."EMPNO"))

END_OUTLINE_DATA

*/

PLAN_TABLE_OUTPUT

------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

2 - access("EMPNO"=7788)

Column Projection Information (identified by operation id):

-----------------------------------------------------------

1 - "EMPNO"[NUMBER,22], "ENAME"[VARCHAR2,10], "SAL"[NUMBER,22],

"DEPTNO"[NUMBER,22]

2 - "EMP".ROWID[ROWID,10], "EMPNO"[NUMBER,22]

46 rows selected.

Elapsed: 00:00:00.06

12:50:21 SCOTT@ prod>

这种方法在 SQLPLUS中查看刚执行过的 SQLSQLSQL的执行计划 。

-- dbms_xplan.display_cursor传入的前两个参数值均为 null,null第三个参数是 "advanced"第三个参 数也可以是 "all"得到的显示结果,少了 "Outline data"部分的内容 。

sql>select sql_text,sql_id,hash_value,child_number from v$sql

2*  where sql_text like 'select empno,ename,sal%'

SQL_TEXT                                           SQL_ID        HASH_VALUE CHILD_NUMBER

-------------------------------------------------- ------------- ---------- ------------

select empno,ename,sal,deptno from emp where empno bqz9ujgnn4jzu 3913435130            0

=7788

Elapsed: 00:00:00.04

13:00:25 SCOTT@ prod>select * from table(dbms_xplan.display_cursor('bqz9ujgnn4jzu',0,'advanced'));

PLAN_TABLE_OUTPUT

------------------------------------------------------------------------------------------------------

SQL_ID  bqz9ujgnn4jzu, child number 0

-------------------------------------

select empno,ename,sal,deptno from emp where empno=7788

Plan hash value: 2949544139

--------------------------------------------------------------------------------------

| Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |

--------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT            |        |       |       |     2 (100)|          |

|   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    46 |     2   (0)| 00:00:01 |

|*  2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     1   (0)| 00:00:01 |

--------------------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):

-------------------------------------------------------------

PLAN_TABLE_OUTPUT

------------------------------------------------------------------------------------------------------

1 - SEL$1 / EMP@SEL$1

2 - SEL$1 / EMP@SEL$1

Outline Data

-------------

/*+

BEGIN_OUTLINE_DATA

IGNORE_OPTIM_EMBEDDED_HINTS

OPTIMIZER_FEATURES_ENABLE('11.2.0.1')

DB_VERSION('11.2.0.1')

ALL_ROWS

OUTLINE_LEAF(@"SEL$1")

INDEX_RS_ASC(@"SEL$1" "EMP"@"SEL$1" ("EMP"."EMPNO"))

END_OUTLINE_DATA

*/

PLAN_TABLE_OUTPUT

------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

2 - access("EMPNO"=7788)

Column Projection Information (identified by operation id):

-----------------------------------------------------------

1 - "EMPNO"[NUMBER,22], "ENAME"[VARCHAR2,10], "SAL"[NUMBER,22],

"DEPTNO"[NUMBER,22]

2 - "EMP".ROWID[ROWID,10], "EMPNO"[NUMBER,22]

46 rows selected.

Elapsed: 00:00:00.14

3、通过DBMS_XPLAN.display_awr

使用方法dbms_xplan.display_cursor 能够得到sql执行计划的前提条件是该SQL还 在共享池中,而如果执行计划的前提条件是该SQL还在共享池中,而如果执行计划的前提条件是该 还在共享池中,而如果SQLSQLSQL的执行计划已经被刷出共享池,那么只要该SQL的执行计划被ORACLE采集到 AWR Repository中, 就可以用该方法来查看 。

12:24:00 SCOTT@ prod>select empno,ename,sal,deptno from emp where empno=7788;

13:10:56 SYS@ prod>exec dbms_workload_repository.create_snapshot;

PL/SQL procedure successfully completed.

13:11:37 SYS@ prod>alter system flush shared_pool;

System altered.

Elapsed: 00:00:00.31

13:16:28 SYS@ prod>select * from table(dbms_xplan.display_cursor('bqz9ujgnn4jzu',0,'advanced'));

PLAN_TABLE_OUTPUT

------------------------------------------------------------------------------------------------------

SQL_ID: bqz9ujgnn4jzu, child number: 0 cannot be found

13:21:53 SYS@ prod>desc dbms_xplan

FUNCTION DISPLAY_AWR RETURNS DBMS_XPLAN_TYPE_TABLE

Argument Name                  Type                    In/Out Default?

------------------------------ ----------------------- ------ --------

SQL_ID                         VARCHAR2                IN

PLAN_HASH_VALUE                NUMBER(38)              IN     DEFAULT

DB_ID                          NUMBER(38)              IN     DEFAULT

FORMAT                         VARCHAR2                IN     DEFAULT

13:30:15 SCOTT@ prod>select * from table(dbms_xplan.display_awr('bqz9ujgnn4jzu'));

PLAN_TABLE_OUTPUT

------------------------------------------------------------------------------------------------------

SQL_ID bqz9ujgnn4jzu

--------------------

select empno,ename,sal,deptno from emp where empno=7788

Plan hash value: 2949544139

--------------------------------------------------------------------------------------

| Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |

--------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT            |        |       |       |     2 (100)|          |

|   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    46 |     2   (0)| 00:00:01 |

|   2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     1   (0)| 00:00:01 |

--------------------------------------------------------------------------------------

14 rows selected.

Elapsed: 00:00:00.30

4、通过10046 事件查看

1)查看当前session:

13:29:52 SYS@ prod>grant alter session to scott;

Grant succeeded.

13:44:31 SCOTT@ prod>alter session set events '10046 trace name context forever,level 12';

Session altered.

13:44:53 SCOTT@ prod>select empno,ename,sal,deptno from emp where empno=7788;

EMPNO ENAME             SAL     DEPTNO

---------- ---------- ---------- ----------

7788 SCOTT            3000         20

Elapsed: 00:00:00.10

13:45:51 SCOTT@ prod>alter session set events '10046 trace name context off';

Session altered.

Elapsed: 00:00:00.03

[oracle@rh6 ~]$ ls -lt /u01/app/oracle/diag/rdbms/prod/prod/trace/|more

total 1256

-rw-r----- 1 oracle oinstall 27801 May 16 13:46 prod_ora_4995.trc

-rw-r----- 1 oracle oinstall   177 May 16 13:46 prod_ora_4995.trm

-rw-r----- 1 oracle oinstall  1122 May 16 13:34 prod_j000_5188.trc

-rw-r----- 1 oracle oinstall    59 May 16 13:34 prod_j000_5188.trm

......

[oracle@rh6 ~]$ tkprof /u01/app/oracle/diag/rdbms/prod/prod/trace/prod_ora_4995.trc /home/oracle/emp_0416.txt sys=no

TKPROF: Release 11.2.0.1.0 - Development on Fri May 16 13:47:41 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

[oracle@rh6 ~]$ cat emp_0416.txt

SQL ID: bqz9ujgnn4jzu

Plan Hash: 2949544139

select empno,ename,sal,deptno

from

emp where empno=7788

call     count       cpu    elapsed       disk      query    current        rows

------- ------  -------- ---------- ---------- ---------- ----------  ----------

Parse        1      0.07       0.09          1         66          0           0

Execute      1      0.00       0.00          0          0          0           0

Fetch        2      0.00       0.00          0          2          0           1

------- ------  -------- ---------- ---------- ---------- ----------  ----------

total        4      0.07       0.09          1         68          0           1

Misses in library cache during parse: 1

Optimizer mode: ALL_ROWS

Parsing user id: 84

Rows     Row Source Operation

-------  ---------------------------------------------------

1  TABLE ACCESS BY INDEX ROWID EMP (cr=2 pr=0 pw=0 time=0 us cost=2 size=46 card=1)

1   INDEX UNIQUE SCAN PK_EMP (cr=1 pr=0 pw=0 time=0 us cost=1 size=0 card=1)(object id 73202)

Elapsed times include waiting on following events:

Event waited on                             Times   Max. Wait  Total Waited

----------------------------------------   Waited  ----------  ------------

db file sequential read                         1        0.00          0.00

SQL*Net message to client                       2        0.00          0.00

SQL*Net message from client                     2       19.13         19.13

********************************************************************************

2)查看其它session:

14:12:23 SYS@ prod>select sid,serial#,username from v$session where username is not null;

SID    SERIAL# USERNAME

---------- ---------- ------------------------------

1          5 SYS

42          9 SCOTT

6 rows selected.

Elapsed: 00:00:00.10

14:12:47 SYS@ prod>desc dbms_monitor

PROCEDURE SESSION_TRACE_DISABLE

Argument Name                  Type                    In/Out Default?

------------------------------ ----------------------- ------ --------

SESSION_ID                     BINARY_INTEGER          IN     DEFAULT

SERIAL_NUM                     BINARY_INTEGER          IN     DEFAULT

PROCEDURE SESSION_TRACE_ENABLE

Argument Name                  Type                    In/Out Default?

------------------------------ ----------------------- ------ --------

SESSION_ID                     BINARY_INTEGER          IN     DEFAULT

SERIAL_NUM                     BINARY_INTEGER          IN     DEFAULT

WAITS                          BOOLEAN                 IN     DEFAULT

BINDS                          BOOLEAN                 IN     DEFAULT

PLAN_STAT                      VARCHAR2                IN     DEFAULT

14:13:11 SCOTT@ prod>select sid from v$mystat where rownum=1;

SID

----------

42

14:13:41 SYS@ prod>exec dbms_monitor.SESSION_TRACE_ENABLE(42,9,waits=>true,binds=>true);

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.10

14:13:25 SCOTT@ prod>select empno,ename,sal,deptno from emp where empno=7369;

EMPNO ENAME             SAL     DEPTNO

---------- ---------- ---------- ----------

7369 SMITH             800         20

Elapsed: 00:00:00.03

14:14:29 SYS@ prod>exec dbms_monitor.SESSION_TRACE_disable(42,9);

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.02

[oracle@rh6 ~]$ cat emp_0416.txt

SQL ID: fyydvbdw2uq6q

Plan Hash: 2949544139

select empno,ename,sal,deptno

from

emp where empno=7369

call     count       cpu    elapsed       disk      query    current        rows

------- ------  -------- ---------- ---------- ---------- ----------  ----------

Parse        1      0.00       0.00          0          0          0           0

Execute      1      0.00       0.00          0          0          0           0

Fetch        2      0.00       0.00          0          2          0           1

------- ------  -------- ---------- ---------- ---------- ----------  ----------

total        4      0.00       0.00          0          2          0           1

Misses in library cache during parse: 1

Optimizer mode: ALL_ROWS

Parsing user id: 84

Rows     Row Source Operation

-------  ---------------------------------------------------

1  TABLE ACCESS BY INDEX ROWID EMP (cr=2 pr=0 pw=0 time=0 us cost=2 size=46 card=1)

1   INDEX UNIQUE SCAN PK_EMP (cr=1 pr=0 pw=0 time=0 us cost=1 size=0 card=1)(object id 73202)

Elapsed times include waiting on following events:

Event waited on                             Times   Max. Wait  Total Waited

----------------------------------------   Waited  ----------  ------------

SQL*Net message to client                       2        0.00          0.00

SQL*Net message from client                     1        0.00          0.00

 

5、通过autotrace查看

SET AUTOTRACE ON
SET AUTOTRACE TRACEONLY
SET AUTOTRACE TRACEONLY EXPLAIN
--使用SET AUTOTRACE ON和SET AUTOTRACE TRACEONLY时,目标SQL已经被执行过,所以在SET AUTOTRACE ON和SET AUTOTRACE TRACEONLY 的情况下能看到目标SQL
的实际消耗情况。
--使用SET AUTOTRACE TRACEONLY EXPLAIN时,如果执行的是SELECT语句,则该SQL并没有被执行,但如果执行的是DML语句,情况就不一样了,此时的DML语句是会
被ORACLE执行的。
--需要特别说明的是,虽然使用SET AUTOTRACE命令所得到的执行计划可能是不准确的,因为SET AUTOTRACE命令所显示的执行计划都是源自于explain plan 命令。

案例:

15:32:11 SYS@ prod>conn scott/tiger

Connected.

15:32:17 SCOTT@ prod>set autotrace on

15:32:21 SCOTT@ prod>select empno,ename,sal,deptno from emp where empno=7788;

EMPNO ENAME             SAL     DEPTNO

---------- ---------- ---------- ----------

7788 SCOTT            3000         20

Elapsed: 00:00:00.03

Execution Plan

----------------------------------------------------------

Plan hash value: 2949544139

--------------------------------------------------------------------------------------

| Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |

--------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT            |        |     1 |    46 |     2   (0)| 00:00:01 |

|   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    46 |     2   (0)| 00:00:01 |

|*  2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     1   (0)| 00:00:01 |

--------------------------------------------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

2 - access("EMPNO"=7788)

Statistics

----------------------------------------------------------

168  recursive calls

0  db block gets

38  consistent gets

0  physical reads

0  redo size

736  bytes sent via SQL*Net to client

523  bytes received via SQL*Net from client

2  SQL*Net roundtrips to/from client

5  sorts (memory)

0  sorts (disk)

1  rows processed

15:32:26 SCOTT@ prod>set autotrace trace

15:32:49 SCOTT@ prod>select empno,ename,sal,deptno from emp where empno=7788;

Elapsed: 00:00:00.02

Execution Plan

----------------------------------------------------------

Plan hash value: 2949544139

--------------------------------------------------------------------------------------

| Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |

--------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT            |        |     1 |    46 |     2   (0)| 00:00:01 |

|   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    46 |     2   (0)| 00:00:01 |

|*  2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     1   (0)| 00:00:01 |

--------------------------------------------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

2 - access("EMPNO"=7788)

Statistics

----------------------------------------------------------

0  recursive calls

0  db block gets

2  consistent gets

0  physical reads

0  redo size

736  bytes sent via SQL*Net to client

523  bytes received via SQL*Net from client

2  SQL*Net roundtrips to/from client

0  sorts (memory)

0  sorts (disk)

1  rows processed

15:34:59 SCOTT@ prod>set autotrace on exp

15:35:04 SCOTT@ prod>select empno,ename,sal,deptno from emp where empno=7788;

EMPNO ENAME             SAL     DEPTNO

---------- ---------- ---------- ----------

7788 SCOTT            3000         20

Elapsed: 00:00:00.02

Execution Plan

----------------------------------------------------------

Plan hash value: 2949544139

--------------------------------------------------------------------------------------

| Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |

--------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT            |        |     1 |    46 |     2   (0)| 00:00:01 |

|   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    46 |     2   (0)| 00:00:01 |

|*  2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     1   (0)| 00:00:01 |

--------------------------------------------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

2 - access("EMPNO"=7788)

15:35:12 SCOTT@ prod>set autotrace on statis

15:35:20 SCOTT@ prod>select empno,ename,sal,deptno from emp where empno=7788;

EMPNO ENAME             SAL     DEPTNO

---------- ---------- ---------- ----------

7788 SCOTT            3000         20

Elapsed: 00:00:00.03

Statistics

----------------------------------------------------------

0  recursive calls

0  db block gets

2  consistent gets

0  physical reads

0  redo size

736  bytes sent via SQL*Net to client

523  bytes received via SQL*Net from client

2  SQL*Net roundtrips to/from client

0  sorts (memory)

0  sorts (disk)

1  rows processed

15:35:26 SCOTT@ prod>

Oracle查看SQL执行计划的方式的更多相关文章

  1. 查看SQL执行计划

    一用户进入某界面慢得要死,查看SQL执行计划如下(具体SQL语句就不完全公布了,截断的如下): call     count       cpu    elapsed       disk       ...

  2. EXPLAIN 查看 SQL 执行计划

    EXPLAIN 查看 SQL 执行计划.分析索引的效率: id:id 列数字越大越先执行: 如果说数字一样大,那么就从上往下依次执行,id列为null的就表是这是一个结果集,不需要使用它来进行查询. ...

  3. plsql中查看sql执行计划

    想要优化sql语句,可以从sql执行计划入手. 在plsql客户端,提供了一个方便的按钮来查看执行计划 选中需要查看的sql语句,点击此按钮,就可以看到该条语句的执行计划了. 结果集包括描述,用户,对 ...

  4. 利用AWR 查看SQL 执行计划

    在AWR中定位到问题SQL语句后想要了解该SQL statement的具体执行计划,于是就用AWR报告中得到的SQL ID去V$SQL等几个动态性能视图中查询,但发现V$SQL或V$SQL_PLAN视 ...

  5. explain查看sql执行计划

    http://www.cnblogs.com/wolf-sun/p/5291563.html 一该命令作用:该命令会向您展示查询是如何被执行的. 1.各个项的含义:https://blog.csdn. ...

  6. PostgreSQL环境中查看SQL执行计划示例

    explain   analyze ,format,buffers, format :TEXT, XML, JSON, or YAML. EXPLAIN (ANALYZE,buffers,format ...

  7. 查看Oracle SQL执行计划的常用方式

    在查看SQL执行计划的时候有很多方式 我常用的方式有三种 SQL> explain plan for 2 select * from scott.emp where ename='KING'; ...

  8. Oracle之SQL优化专题01-查看SQL执行计划的方法

    在我2014年总结的"SQL Tuning 基础概述"中,其实已经介绍了一些查看SQL执行计划的方法,但是不够系统和全面,所以本次SQL优化专题,就首先要系统的介绍一下查看SQL执 ...

  9. oracle sql 执行计划分析

    转自http://itindex.net/detail/45962-oracle-sql-%E8%AE%A1%E5%88%92 一.首先创建表 SQL> show user USER is &q ...

随机推荐

  1. python 中logging模块

    logging的作用:python中,logging模块主要是处理日志的.所谓日志,可理解为在软件运行过程中,所记录的的一些运行情况信息,软件开发人员可以根据自己的需求添加日志,日志可以帮助软件开发人 ...

  2. 背景图片的移动----background-attach-----background-repeat

    background-repeat:默认是平铺的,也即是还有空间的话将一张接着一张显示 设置为 no-repeat  就最多显示一张 background-attachment:设置是否固定图片,在有 ...

  3. 轻松解决oracle11g 空表不能exp导出的问题。

    解决方法: 1插入一条数据(或者再删除),浪费时间,有时几百张表会累死的.2创建数据库之前使用代码: Sql代码 alter system set  deferred_segment_creation ...

  4. windows定时关机命令

    at 11:00 shutdown.exe -s -t 120 https://jingyan.baidu.com/article/574c52191ea9996c8c9dc17a.html?st=2 ...

  5. Retrofit简介与使用方法(翻译)

    简介 Retrofit 是一个Square开发的类型安全的REST安卓客户端请求库.这个库为网络认证.API请求以及用OkHttp发送网络请求提供了强大的框架.Retrofit库让从web api下载 ...

  6. postgresql----COPY之表与文件之间的拷贝

    postgresql提供了COPY命令用于表与文件(和标准输出,标准输入)之间的相互拷贝,copy to由表至文件,copy from由文件至表. 示例1.将整张表拷贝至标准输出 test=# cop ...

  7. sql中有一些保留字,当你的字段名是它的保留字时,这个时候sql语句的字段不加``就会报错

    sql中有一些保留字,当你的字段名是它的保留字时,这个时候sql语句的字段不加``就会报错

  8. ubuntu简单安装apache

    环境: ubuntu 目标: 1.安装web服务器apache 2.打开浏览器,访问自己的web服务器,看到 Hello,World! 开始动手了! 安装sudo apt-get install ap ...

  9. Firefox What's New 太难找了

    Firefox每次更新版本,不知道更新了什么,找不到Waht‘s New,做个记录! 1.点击mozilla下拉 2.最左侧 MOZILLA>SUPPORT>Firefox 3.https ...

  10. WeakReference与SoftReference

    WeakReference与SoftReference都可以用来保存对象的实例引用,这两个类与垃圾回收有关. WeakReference是弱引用,其中保存的对象实例可以被GC回收掉.这个类通常用于在某 ...