简体   繁体   English

分区表-直接插入还是首先创建临时表并切换?

[英]Partitioned table - insert directly or create a staging table first and switch in?

Is it the same regarding to the performance (or the difference can be neglected)? 关于性能是否相同(或差异可以忽略)? The data to be inserted are all in the new partition. 要插入的数据全部在新分区中。

Depends on current load on the table, indexes on it - (if exists index, which is not partitioned, can cause problems). 取决于表上当前的负载,表上的索引-(如果存在未分区的索引,则可能导致问题)。 Actually - depends. 实际上-取决于。 Try on your test simulating load environment. 尝试测试模拟负载环境。

Current load influences: 当前负载影响:

It may be negligible, or not, need to test, but if table under high insert/update/read load, then inserting data row by row into the table will cause to big amount of short-time locks, but overall wait time may be significant. 可能需要测试还是可以忽略不计,但是如果表在高插入/更新/读取负载下,则将数据逐行插入表中将导致大量的短时锁定,但总的等待时间可能是重大。 So - switching partition can significantly reduce overall locking time, since you have no indexes other than clustered 因此-切换分区可以显着减少总体锁定时间,因为除了集群索引以外,您没有其他索引

Also this can cause to deadlocks when you'll try to read subset of data with filter other than clustered index/primary key (since you have no any indexes on table except clustered) - this will cause to clustered index scan and if there will be an inserted/updated record during this scan - it may cause deadlock. 当您尝试使用除聚簇索引/主键之外的过滤器读取数据子集时,这也会导致死锁(因为除了聚簇之外,表上没有任何索引)–这将导致聚簇索引扫描,并且如果存在在此扫描过程中插入/更新的记录-可能导致死锁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM