在空表上创建索引后插入数据还是在oracle上插入数据后创建唯一索引?

2021-12-21 00:00:00 indexing performance sql insert oracle

哪个选项更好更快?在空表上创建索引后插入数据或在插入数据后创建唯一索引.我有大约 10M 行要插入.哪个选项会更好,以便我可以减少停机时间.

Which option is better and faster? Insertion of data after creating index on empty table or creating unique index after inserting data. I have around 10M rows to insert. Which option would be better so that I could have least downtime.

推荐答案

先插入数据,然后创建索引.

Insert your data first, then create your index.

每次执行 UPDATE、INSERT 或 DELETE 操作时,表上的任何索引也必须更新.因此,如果您先创建索引,然后插入 10M 行,则索引也必须更新 10M 次(除非您正在执行批量操作).

Every time you do an UPDATE, INSERT or DELETE operation, any indexes on the table have to be updated as well. So if you create the index first, and then insert 10M rows, the index will have to be updated 10M times as well (unless you're doing bulk operations).

相关文章