The constraint also helps speed up the query.
来源:互联网 发布:黑帽seo零基础学习 编辑:程序博客网 时间:2024/06/06 18:28
As we know the constraint is an object to keep data integrity in oracle database.
But it is also help accelerate the query.So we should not disable the contraint simply just because our data is cleansed in our database warehouse. Let us look the following test on this.
$ sqlplus /
SQL*Plus: Release 10.2.0.3.0 - Production on Sun Nov 28 23:51:53 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Oracle Label Security, OLAP
and Data Mining options
SQL> create table t as select * from all_objects;
Table created.
SQL> create index t_idx on t(object_type);
Index created.
SQL> exec dbms_stats.gather_table_stats(user,'T');
PL/SQL procedure successfully completed.
SQL> select count(*) from t;
Execution Plan
----------------------------------------------------------
Plan hash value: 1842905362
-------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
-------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 233 (3)| 00:00:02 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | TABLE ACCESS FULL| T | 52862 | 233 (3)| 00:00:02 |
-------------------------------------------------------------------
SQL> alter table t modify object_type not null;
Table altered.
SQL> select count(*) from t;
Execution Plan
----------------------------------------------------------
Plan hash value: 1799443504
-----------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
-----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 49 (7)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | INDEX FAST FULL SCAN| T_IDX | 52862 | 49 (7)| 00:00:01 |
-----------------------------------------------------------------------
SQL> alter table t modify object_type null;
Table altered.
SQL> select * from t where object_type is null;
Execution Plan
----------------------------------------------------------
Plan hash value: 2153619298
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 94 | 236 (4)| 00:00:02 |
|* 1 | TABLE ACCESS FULL| T | 1 | 94 | 236 (4)| 00:00:02 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OBJECT_TYPE" IS NULL)
SQL> drop index t_idx;
Index dropped.
SQL> create index t_idx on t(object_type,0);
Index created.
SQL> select * from t where object_type is null;
Execution Plan
----------------------------------------------------------
Plan hash value: 1020776977
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 94 | 1 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 1 | 94 | 1 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | T_IDX | 1 | | 1 (0)| 00:00:01 |
-------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_TYPE" IS NULL)
- The constraint also helps speed up the query.
- How to speed up the MV refresh
- the method to speed up your app
- the Beginning also the End
- Speed Up Multiple SSH Connections to the Same Server
- How LED lights could speed up the internet
- Tips for speed up your algorithm in the CUDA programming
- Zen of PM - Getting the team up to speed
- Using MAAS + Juju to speed up the cloud deployment under the VMs (by quqi99)
- [howto] General 5.10 - HowTo: Speed up ubuntu boot process - the way you can feel it. - updated
- Ten ways to speed up the download time of your web pages
- 加速下载ios的sdk(Speed up the download of xcode)
- comments on "the sun also rises"
- The introvert can also be leaders
- so slow of the speed
- Ruby EventMachine - The Speed Demon
- Question 23: Which of the following C++ keywords are designed to speed up execution of a C++ function?
- Up the creek 进退两难
- 源码资料下载网站,资料都不错,极力推荐
- LAMP兄弟连原创Linux视频教程-第2讲Linux系统安装[免费下载]
- Warning: Missing argument 2问题
- tomcat 6.X weblogic 10.X
- 表空间对用户的管理
- The constraint also helps speed up the query.
- 最长公共子序列 POJ 2250
- vs 2008 快捷键
- 2010-11-29 情况
- Wince程序内存和存储内存
- 解惑Spring嵌套事务
- 角点检测(Corner Detection) cvFindCornerSubPix 使用范例
- 深入Java核心 Java内存分配原理精讲(网络转载)
- 如何取得Android源代码