惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
L
LINUX DO - 热门话题
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
Cisco Talos Blog
Cisco Talos Blog
AI
AI
L
LINUX DO - 最新话题
H
Heimdal Security Blog
Hacker News: Ask HN
Hacker News: Ask HN
Webroot Blog
Webroot Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The GitHub Blog
The GitHub Blog
I
Intezer
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
S
Securelist
博客园_首页
IT之家
IT之家
Schneier on Security
Schneier on Security
博客园 - 叶小钗
罗磊的独立博客
WordPress大学
WordPress大学
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
W
WeLiveSecurity
The Register - Security
The Register - Security
D
DataBreaches.Net
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
Recorded Future
Recorded Future
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tailwind CSS Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
T
Tor Project blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com

博客园 - 何随风

安装JAVA 商业模式画布 Valve新员工手册中文版 Failure is not fatal, but failure to change might be. 降低依赖重复的两项优化 IntelliJ IDEA 我的配置--留个脚印 Maven更新父子模块的版本号 Maven更新子模块的版本号 qq centos下安装ZooKeeper centos下配置java环境变量 vbox导入虚拟电脑网卡MAC问题 Linux下连接MSSQL之安装FreeTDS 独特的方法看问题 未来八种人将被社会淘汰 分析学习MYSQL源代码需要哪些方面的知识呢? 一个分号引发的思考 读到的"关于授权" 网站一开启网站访问硬盘读取就变慢
MSSQL大数据量增加字段耗时对比
何随风 · 2016-08-02 · via 博客园 - 何随风

单个数据表记录数为1亿4千万条.

一、测试同时增加两个允许为空的字段.

ALTER TABLE [dbo].[XRecord] ADD [sType] int,[cType] int

GO

开始时间:2016-08-02 14:55:33.553

完成时间:2016-08-02 14:55:34.430

总共耗时:877毫秒

更新数据值

UPDATE [dbo].[XRecord] SET [sType]=0,[cType]=0

开始时间:2016-08-02 15:01:46.293

完成时间:2016-08-02 16:38:39.230

总共耗时:1小时37分

增加字段描述

使用sp_addextendedproperty和sp_updateextendedproperty操作

开始时间:2016-08-02 17:13:34.557

完成时间:2016-08-02 17:13:36.050

总共耗时:1.5秒

二、试同时增加两个不允许为空的字段

ALTER TABLE [dbo].[XRecord] ADD [sType] int NOT NULL,[cType] int NOT NULL

GO

开始时间:2016-08-02 17:16:04.580

完成时间:2016-08-02 18:07:39.247

总共耗时:51分钟35秒

三、修改字段的默认值

BEGIN TRANSACTION
GO
ALTER TABLE [dbo].[XRecord] ADD CONSTRAINT
    DF_P_XRecord_cType DEFAULT 999999 FOR cType
GO
ALTER TABLE [dbo].[XRecord]SET (LOCK_ESCALATION = TABLE)
GO
COMMIT

开始时间:2016-08-02 18:08:56.680

完成时间:2016-08-02 18:08:58.165

总共耗时:0分钟1秒

四、增加字段同时设置非空及默认值

BEGIN TRANSACTION
GO
ALTER TABLE [dbo].[XRecord] ADD [sType] int NOT NULL DEFAULT 0 , [cType] int NOT NULL DEFAULT 0
GO
ALTER TABLE [dbo].[XRecord] SET (LOCK_ESCALATION = TABLE)
GO
COMMIT

开始时间:2016-09-08 11:47:21

完成时间:2016-09-08  13:45:41

总共耗时:1小时58分钟20秒191毫秒

五、增加字段同时设置默认值

BEGIN TRANSACTION
GO
ALTER TABLE [dbo].[XRecord] ADD [serviceType2] int DEFAULT 0 , [costType2] int DEFAULT 0
GO
ALTER TABLE dbo.XRecord SET (LOCK_ESCALATION = TABLE)
GO
COMMIT

开始时间:2016-09-08 13:52:37.977

完成时间:2016-09-08 13:52:38.913

总共耗时:996毫秒

注:以上测试均在没有其他用户操作数据库及没有从库的情况下执行.