起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 537|回复: 3

执行update语句速度慢,发现分析索引导致

[复制链接]
发表于 2012-7-5 15:04:12 | 显示全部楼层 |阅读模式
数据库是oracle9,
执行下面的语句:
update MAT_BUY_PLAN_B set supplier_cod='dd' where id='ddd' and supplier_cod is null;
其中,ID是关键字,执行速度慢,通过sqlmoniter跟踪发现分析表MAT_BUY_PLAN_B索引的时间超长接近1分钟,为什么会执行下面的内容,有什么办法不执行吗?!

Timestamp: 13:57:23.234
SELECT 1 AS scope, 'ROWID' AS column_name, -8 AS data_type,
       'ROWID' AS type_name, 0 AS column_size, 0 AS buffer_length,
       0 AS decimal_digits, 2 AS pseudo_column
FROM DUAL
WHERE :1 = 1
UNION
SELECT 2 AS scope,
       t.column_name,
       DECODE (t.data_type, 'CHAR', 1, 'VARCHAR2', 12, 'NUMBER', 3,
               'LONG', -1, 'DATE', 93, 'RAW', -3, 'LONG RAW', -4, 1111)
              AS data_type,
       t.data_type AS type_name,
       DECODE (t.data_precision, null, t.data_length, t.data_precision)
              AS column_size,
       0 AS buffer_length,
       t.data_scale AS decimal_digits,
       1 AS pseudo_column
FROM all_tab_columns t, all_ind_columns i
WHERE :2 = 1
  AND t.table_name = :3
  AND t.owner like :4 escape '/'
  AND t.nullable != :5
  AND t.owner = i.table_owner
  AND t.table_name = i.table_name
  AND t.column_name = i.column_name
:1 = 1
:2 = 1
:3 = 'MAT_BUY_PLAN_B'
:4 = '%'
:5 = 'X'
----------------------------------
Timestamp: 13:57:23.296
SELECT NULL AS table_cat,
       c.owner AS table_schem,
       c.table_name,
       c.column_name,
       c.position AS key_seq,
       c.constraint_name AS pk_name
FROM all_cons_columns c, all_constraints k
WHERE k.constraint_type = 'P'
  AND k.table_name = :1
  AND k.owner like :2 escape '/'
  AND k.constraint_name = c.constraint_name
  AND k.table_name = c.table_name
  AND k.owner = c.owner
ORDER BY column_name
:1 = 'MAT_BUY_PLAN_B'
:2 = '%'
----------------------------------
Timestamp: 13:57:29.796
analyze table MAT_BUY_PLAN_B estimate statistics
----------------------------------
Timestamp: 13:57:29.859
select null as table_cat,
       owner as table_schem,
       table_name,
       0 as NON_UNIQUE,
       null as index_qualifier,
       null as index_name, 0 as type,
       0 as ordinal_position, null as column_name,
       null as asc_or_desc,
       num_rows as cardinality,
       blocks as pages,
       null as filter_condition
from all_tables
where table_name = 'MAT_BUY_PLAN_B'
union
select null as table_cat,
       i.owner as table_schem,
       i.table_name,
       decode (i.uniqueness, 'UNIQUE', 0, 1),
       null as index_qualifier,
       i.index_name,
       1 as type,
       c.column_position as ordinal_position,
       c.column_name,
       null as asc_or_desc,
       i.distinct_keys as cardinality,
       i.leaf_blocks as pages,
       null as filter_condition
from all_indexes i, all_ind_columns c
where i.table_name = 'MAT_BUY_PLAN_B'
  and i.uniqueness = 'UNIQUE'
  and i.index_name = c.index_name
  and i.table_owner = c.table_owner
  and i.table_name = c.table_name
  and i.owner = c.index_owner
order by non_unique, type, index_name, ordinal_position
回复

使用道具 举报

 楼主| 发表于 2012-7-6 09:43:56 | 显示全部楼层
有知道的吗,这个索引分析是justep平台做的吗
回复 支持 反对

使用道具 举报

发表于 2012-7-8 14:48:38 | 显示全部楼层
一看这个 MAT_BUY_PLAN_B 命名就不是justep的风格。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-7-10 15:59:23 | 显示全部楼层
当然表名是我自己起的,就是我执行个update语句,导致分析这个表的索引 不是我写的
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2024-5-4 12:41 , Processed in 0.068084 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表