我编写了一个PL/SQL过程,如果首先禁用索引,然后在完成时重建,那么这个过程将会受益.一个现有线程表明这种方法:
alter session set skip_unusable_indexes = true;
alter index your_index unusable;
Run Code Online (Sandbox Code Playgroud)
[做导入]
alter index your_index rebuild;
Run Code Online (Sandbox Code Playgroud)
但是,我在第一个alter index语句中收到以下错误:
SQL Error: ORA-14048: a partition maintenance operation may not be combined with other operations
ORA-06512: [...]
14048. 00000 - "a partition maintenance operation may not be combined with other operations"
*Cause: ALTER TABLE or ALTER INDEX statement attempted to combine
a partition maintenance operation (e.g. MOVE PARTITION) with some
other operation (e.g. ADD PARTITION or PCTFREE which is illegal
*Action: Ensure that a partition maintenance operation is the sole
operation specified in ALTER TABLE or ALTER INDEX statement;
operations other than those dealing with partitions,
default attributes of partitioned tables/indices or
specifying that a table be renamed (ALTER TABLE RENAME) may be
combined at will
Run Code Online (Sandbox Code Playgroud)
问题索引定义如下:
CREATE INDEX A11_IX1 ON STREETS ("SHAPE")
INDEXTYPE IS "SDE"."ST_SPATIAL_INDEX" PARAMETERS
('ST_GRIDS=890,8010,72090 ST_SRID=2');
Run Code Online (Sandbox Code Playgroud)
这是来自第三方供应商的自定义索引类型,在高容量更新/插入/删除操作期间会导致长期性能下降.
有关如何解决此错误的任何建议?顺便说一句,此错误仅发生在PL/SQL块中.
编辑:以下是整个程序:
procedure disable_indexes (
tbl_name in varchar2
) as
stmt varchar2(200);
cursor curs(v_tbl_name in varchar2) is
select 'alter index ' || index_name || ' unusable;' as ddl_stmt
from user_indexes
where upper(table_owner) = upper(user)
and upper(table_name) = upper(v_tbl_name)
and ityp_name in ('CTXCAT', 'ST_SPATIAL_INDEX');
begin
for r_curs in curs(tbl_name) loop
dbms_output.put_line(r_curs.ddl_stmt);
execute immediate r_curs.ddl_stmt;
end loop;
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7584 次 |
| 最近记录: |