- 最后登录
- 2015-1-26
- 在线时间
- 51 小时
- 威望
- 30
- 金钱
- 158
- 注册时间
- 2011-10-14
- 阅读权限
- 10
- 帖子
- 66
- 精华
- 0
- 积分
- 30
- UID
- 32
|
1#
发表于 2013-5-8 18:03:29
|
查看: 4640 |
回复: 8
本帖最后由 sky13and23 于 2013-5-8 18:06 编辑
SQL> explain plan for select a.ICPCODE,a.ICPSERVID,ShortcutText from portal.service a, portal.wap_service b where a.icpcode = b.icpcode and a.icpservid = b.icpservid;
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 34517 | 1078K| 5299 |
| 1 | NESTED LOOPS | | 34517 | 1078K| 5299 |
| 2 | TABLE ACCESS FULL | SERVICE | 1702K| 32M| 5299 |
|* 3 | INDEX UNIQUE SCAN | PK_WAPSERVICE_SERVID | 1 | 12 | |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
---------------------------------------------------
3 - access("A"."ICPCODE"="B"."ICPCODE" AND "A"."ICPSERVID"="B"."ICPSERVID")
Note: cpu costing is off
16 rows selected.
为什么service 表不走索引PK_SERVICE_SERVID
下面是一些统计信息:
SQL> select count(*) from portal.service ;
COUNT(*)
----------
1702774
SQL> select count(*) from portal.wap_service ;
COUNT(*)
----------
34873
SQL> select a.last_analyzed,a.clustering_factor,a.blevel,a.leaf_blocks,a.distinct_keys,
2 a.avg_leaf_blocks_per_key,a.avg_data_blocks_per_key,a.num_rows,a.table_name,a.index_name
3 from dba_indexes a where table_name in ('SERVICE','WAP_SERVICE') and owner = 'PORTAL';
LAST_ANALYZED CLUSTERING_FACTOR BLEVEL LEAF_BLOCKS DISTINCT_KEYS AVG_LEAF_BLOCKS_PER_KEY AVG_DATA_BLOCKS_PER_KEY NUM_ROWS TABLE_NAME INDEX_NAME
------------- ----------------- ---------- ----------- ------------- ----------------------- ----------------------- ---------- ------------------------------ ------------------------------
2013-5-8 17:5 78750 2 4783 1144 4 68 1712433 SERVICE IDX_SERVATTR_ICPCODE
2013-5-8 17:5 1530193 2 6723 1719553 1 1 1719553 SERVICE PK_SERVICE_SERVID
2013-5-7 18:3 15415 1 127 34873 1 1 34873 WAP_SERVICE PK_WAPSERVICE_SERVID
SQL>
SQL>
SQL> select a.last_analyzed,a.blocks,a.num_rows,a.EMPTY_BLOCKS,a.avg_space,
2 a.chain_cnt,a.avg_row_len,a.table_name
3 from dba_tables a where table_name in ('SERVICE','WAP_SERVICE')and owner = 'PORTAL';
LAST_ANALYZED BLOCKS NUM_ROWS EMPTY_BLOCKS AVG_SPACE CHAIN_CNT AVG_ROW_LEN TABLE_NAME
------------- ---------- ---------- ------------ ---------- ---------- ----------- ------------------------------
2013-5-8 17:5 55079 1702023 0 0 0 222 SERVICE
2013-5-7 18:3 1135 34873 0 0 0 100 WAP_SERVICE
|
|