mysql中条件变量_看执行计划时怎么确定select语句的条件变量

[PHP]

Microsoft Windows XP [版本 5.1.2600]

(C) 版权所有 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>oradim -startup -sid test1

C:\Documents and Settings\Administrator>set oracle_sid=test1

C:\Documents and Settings\Administrator>sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on 星期二 8月 28 10:50:51 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

连接到:

Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.4.0 - Production

SQL> conn my_user/my_user

已连接。

SQL> select table_name,index_name from user_indexes;

TABLE_NAME                     INDEX_NAME

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

TEST_PARTITION_TABLE           ID_INDEX

TEST_PARTITION_TABLE           MY_PK_INDEX

TEST_PARTITION_TABLE           MY_UNIQUE_INDEX

TEST_PARTITION_TABLE           NAME_INDEX

MY_TABLE1                      PK_ID

SQL> select * from my_table1;

ID NAME       MY_BIRTHDA

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

1 name1      11-7月 -07

2 name2      24-6月 -06

SQL> select * from test_partition_table;

ID NAME                      MY_ID  MY_UNIQUE

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

88 my_88                         1         10

888 my_888                        2         20

SQL> alter session set events '10046 trace name context forever,level 8';

会话已更改。

SQL> explain plan for select name from my_table1 where id=:1;

已解释。

SQL> alter session set events '10046 trace name context off';

会话已更改。

SQL> @?/rdbms/admin/utlxpls

PLAN_TABLE_OUTPUT

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

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

| Id  | Operation                   |  Name       | Rows  | Bytes | Cost  |

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

|   0 | SELECT STATEMENT            |             |       |       |       |

|   1 |  TABLE ACCESS BY INDEX ROWID| MY_TABLE1   |       |       |       |

|*  2 |   INDEX UNIQUE SCAN         | PK_ID       |       |       |       |

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

Predicate Information (identified by operation id):

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

PLAN_TABLE_OUTPUT

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

2 - access("MY_TABLE1"."ID"=TO_NUMBER(:Z))

Note: rule based optimization

已选择15行。

SQL> truncate table plan_table;

表已截掉。

SQL> exec dbms_stats.gather_table_stats('MY_USER','MY_TABLE1');

PL/SQL 过程已成功完成。

SQL> alter session set events '10046 trace name context forever,level 8';

会话已更改。

SQL> explain plan for select name from my_table1 where id=:1;

已解释。

SQL> alter session set events '10046 trace name context off';

会话已更改。

SQL> @?/rdbms/admin/utlxpls

PLAN_TABLE_OUTPUT

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

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

| Id  | Operation                   |  Name       | Rows  | Bytes | Cost  |

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

|   0 | SELECT STATEMENT            |             |     1 |     9 |     2 |

|   1 |  TABLE ACCESS BY INDEX ROWID| MY_TABLE1   |     1 |     9 |     2 |

|*  2 |   INDEX UNIQUE SCAN         | PK_ID       |     2 |       |     1 |

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

Predicate Information (identified by operation id):

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

PLAN_TABLE_OUTPUT

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

2 - access("MY_TABLE1"."ID"=TO_NUMBER(:Z))

Note: cpu costing is off

已选择15行。

SQL>

[/PHP]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值