这几天在做数据库的优化,有个2亿记录的表,发现需要添加一个联合索引,结果就采用普通的create index index_name
on tablename (entp_id,sell_date),结果悲剧了,把所有的DML语句都阻塞了,导致系统不能正常使用,还好是晚上10点,用户不是非常多,1个小时候,索引结束,阻塞解决;
上网查了一下,如果加上 online参数后,就可以在线做索引,而不需要阻塞所有的DML语句,血的教训,拿出来与各位共勉,具体online与不加online区别如下:
1. DML操作对create index 的影响。 如果在create的时候,有其他的进程在对这个index 所对应的数据进行DML操作,create会受影响:
SQL> create table test (id number, name varchar2(20));
Table created.
--- 然后重新开一个session:
SQL> insert into test values (1,'lms');
1 row created.
<no commit>
SQL> create index t1 on test(id);
create index t1 on test(id)
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified
2. 加online这个参数,这个参数加上以后,除了create过程中index 保持online状态,Oracle还会在create index之前等待所有DML操作结束,然后得到DDL锁,开始create.
SQL> create index t1 on test(id) online;
<hold before commit>
<after commit>
SQL> commit;
Commit complete.
Index altered.
---- 如果不commit,上面的操作就会一直hold。
所以以后create索引和rebuild索引的时候最好加上online。
分享到:
相关推荐
CREATE INDEX Syntax CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name [index_type] ON tbl_name (index_col_name,…) [index_type] index_col_name: col_name [(length)] [ASC | DESC] index_type: USING {...
使用CREATE INDEX语句可以在一个已有表上创建索引,一个表可以创建多个索引。 语法格式: CREATE [UNIQUE | FULLTEXT] INDEX 索引名 ON 表名(列名[(长度)] [ASC | DESC],...) 说明: UNIQUE:表示创建的是唯一性索引 ...
快速重建索引的一种有效的办法,因为使用现有索引项来重建新索引,如果客户操作时有其他用户在对这个表操作,尽量使用带online参数来最大限度的减少索引重建时将会出现的任何加锁问题,alter index index_name ...
unity在线地图Online Maps 2.5.16 需Unity 4.6.0或以上版本 Requires Unity 4.6.0 or higher. Features: ? Supports Unity v4.6+, Unity v5+; ? Standalone, Android, iOS, Windows Store, WebGL, Webplayer;...
Online and offline maps; ? 2D maps and 3D maps with elevation; ? 2D, 3D and Billboard markers; ? Supports Texture, GUITexture, NGUI, DF-GUI, iGUI, SpriteRenderer, uGUI (UIImage, UIRawImage) and ...
【例3.13】为学生—课程数据库中的Student、Course和SC三个表建立索引。其中Student表按学号升序建唯一索引,Course表按课程号升序建唯一索引,SC表按学号升序和课程号降序建唯一索引。 索引建立时可利用关键字修饰...
Online Maps - is a universal mapping solution that is suitable for all applications and games that use a map. Features: •Supports Unity v4.6+, Unity v5+; •Standalone, Android, iOS, Windows Store, ...
报错大致意思就是创建index.lock文件失败,因为已经存在index.lock文件了. index.lock文件是在.git下面, 而.git是一般是隐藏的, 那么可以通过以下命令删除即可. rm -rf /Users/dianji/project/ccpay.h5/.git/index....
在执行CREATE TABLE语句时可以创建索引,也可以单独用CREATE INDEX 或 ALTER TABLE来为表增加索引。 1.ALTER TABLE可以用来创建普通索引、UNIQUE索引或PRIMARY KEY索引。 2.CREATE INDEX可对表增加普通索引或UNIQUE...
数据库管理与应用 4.2.4使用CREATE INDEX语句创建索引.pdf 学习资料 复习资料 教学资源
Teaches you all about e-commerce and how to create your own online shop using WordPress and WooCommerce. Regardless of a business’s size, e-commerce helps level the playing field, increases a ...
而且不能删除当前用户,如果删除的用户有数据对象,那么必须加上关键字cascade。 用法:drop user 用户名 [cascade] 四、 用户权限与角色 1. 权限 Oracle中权限主要分为两种,系统权限和实体权限。 系统权限:...
向线程函数传递参数的程序示例; 一个资源包,执行 tar zxvf example.tar.gz 解压资源; 复制readme.txt中的编译语句,编译得到可执行程序threadtest; ./threadtest 执行皆可看到效果。
Designer Online Guides The following online guides provide complete information for using Designer and other useful information. You can access each of these guides from the product documentation ...
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) GO 尝试2: 可是还需要验证唯一性怎么办呢? ...
如果index.ts中没有仅用于导出的业务逻辑,则create-ts-index有助于轻松导入。 或者,如果您有图书馆项目需要此导出过程(例如,blueprint.js等)。 cti(create-ts-index)创建导出index.ts文件。 例如,下面的...
MySQL数据库操作显⽰数据库创建数据库删除数据库查看数据库的字符集显⽰ 表创建表表选项删除。。。... //如果数据库不存在,再进⾏创建 create database 007online charset utf8; //指定数据库的默
怎样建立最佳索引? 1、明确地创建索引 create index index_name on table_name(field_name) tablespace tablespace_name pctfree 5 initrans 2 maxtrans 255 storage ( minextents 1 maxextents 16382 pctincrease ...
This example is how to create online shopping system using php and mysql