insert tb select ... from table ---其中table表数据大概50万行,table大概300M ,table和tb表结构相同,但是聚集索引不一样。table是每天生成的数据,我在0点自动用作业导入到tb表。然后清空table表。这样下来tb表月末的数据将达到1400万行。现在的问题是:insert tb select ... from table 一次这样插入的效率高,还是while exists(select * from table)
begin
insert tb select top 100000 from table
delete table where id in (select top 100000 id from table)
end
那个效率高?
表 tb 上的聚集索引和 table的聚集索引 不是同一列。
这样我在insert tb 的时候 是不是消耗掉很多时间排序啊
表tb上的聚集索引和table的聚集索引不是同一列。 表tb上聚集索引,要设计合理。比如今天插入的数据,如果tb聚集索引导致之前插入的数据重排,月末的时候,效率是灾难性的。