人大金仓数据库解决了兼容oracle的索引失效问题

关键字

索引失效,禁用索引,启用索引,索引重建、人大金仓、

问题描述

Oracle能够通过语句设置,使索引失效,支持设置索引的启用禁用操作

create table t1(c1 int,c2 varchar(10));

create index idx_t1 on t1(c1);

--禁用索引,设置索引失效

alter index idx_t1 unusable;

--启用索引,重建索引

alter index idx_t1 rebuild;

问题分析

KES不具备设置索引启用,禁用的能力。

解决方案

create index语句添加usable、unusable支持创建索引时指定索引状态,未指定时默认为启用状态。

新增语法:

CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] name ]

ON [ ONLY ] table_name [ USING method ]

( { column_name | ( expression ) } [ COLLATE collation ]

opclass \] \[ ASC \| DESC \] \[ NULLS { FIRST \| LAST } \] \[, ...\] ) \[ INCLUDE ( column_name \[, ...\] )

WITH ( storage_parameter = value \[, ... \] )

TABLESPACE tablespace_name

UNUSABLE \| USABLE

WHERE predicate

描述:

unusable 创建一个不可用状态的索引

usable 创建一个可用状态的索引,默认状态

ALTER INDEX name UNUSABLE

ALTER INDEX name REBUILD

--create index使用

create table tab_btree (id int,name text);

insert into tab_btree values(generate_series(1,100000),md5(random()::text));

create index i_btree on tab_btree using btree(id);

analyze;

explain (costs off) select * from tab_btree where id < 10;

-- alter index name unusable

alter index i_btree unusable;

explain (costs off) select * from tab_btree where id < 10;

-- alter index name rebuild

alter index i_btree rebuild;

explain (costs off) select * from tab_btree where id < 10;

参考资料

相关推荐
洛克大航海31 分钟前
解锁 PySpark SQL 的强大功能:有关 App Store 数据的端到端教程
linux·数据库·sql·pyspark sql
XueminXu2 小时前
ClickHouse数据库的表引擎
数据库·clickhouse·log·表引擎·mergetree·special·integrations
冒泡的肥皂2 小时前
MVCC初学demo(二
数据库·后端·mysql
代码程序猿RIP2 小时前
【Redis 】Redis 详解以及安装教程
数据库·etcd
小生凡一2 小时前
redis 大key、热key优化技巧|空间存储优化|调优技巧(一)
数据库·redis·缓存
oe10192 小时前
好文与笔记分享 A Survey of Context Engineering for Large Language Models(上)
数据库·笔记·语言模型·agent·上下文工程
小马哥编程2 小时前
【软考架构】案例分析-对比MySQL查询缓存与Memcached
java·数据库·mysql·缓存·架构·memcached
一 乐2 小时前
高校后勤报修系统|物业管理|基于SprinBoot+vue的高校后勤报修系统(源码+数据库+文档)
java·前端·javascript·数据库·vue.js·毕设
折翼的恶魔3 小时前
SQL190 0级用户高难度试卷的平均用时和平均得分
java·数据库
煎蛋学姐3 小时前
SSM基于框架在线电影评论投票系统3gr0f(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
数据库·系统开发·ssm 框架·在线电影评论投票系统