国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > SQL Server > 正文

Sql Server Tempdb原理-日志機制解析實踐

2024-08-31 00:55:28
字體:
來源:轉載
供稿:網友
Sql Server Tempdb原理-日志機制解析實踐

筆者曾經在面試DBA時的一句”tempdb為什么比其他數據庫快?”使得95%以上的應試者都一臉茫然.Tempdb作為Sqlserver的重要特征,一直以來大家對它可能即熟悉又陌生.熟悉是我們時時刻刻都在用,陌生可能是很少有人關注它的運行機制.這次我將通過實例給大家介紹下tempdb的日志機制.

測試用例

我們分別在用戶數據庫(testpage),tempdb中創建相似對象t1,#t1,并在tempdb中創建創建非臨時表,然后執行相應的insert腳本(用以產生日志),并記錄執行時間用以比較用以比較說明tempdb”快”

Code

用戶數據庫testpage

use testpagegocreate table t1(id int identity(1,1) not null,str1 char(8000))declare @t datetime2=sysutcdatetime()declare @i intset @i=1while (@i<100000)begininsert into t1 select @i,'aa'select @i=@i+1endselect [extime]=DATEDIFF(S,@t,sysutcdatetime())

tempdb

use tempdbgocreate table #t1(id int not null,str1 char(8000))declare @t datetime2=sysutcdatetime()declare @i intset @i=1while (@i<100000)begininsert into #t1 select @i,'aa'select @i=@i+1endselect [extime]=DATEDIFF(S,@t,sysutcdatetime())

非臨時表在tempdb中執行

use tempdbgocreate table t1(id int not null,str1 char(8000))declare @t datetime2=sysutcdatetime()declare @i intset @i=1while (@i<100000)begininsert into t1 select @i,'aa'select @i=@i+1endselect [extime]=DATEDIFF(S,@t,sysutcdatetime())

由圖1-1中我們可以看出,在普通表中執行一分鐘的腳本,tempdb只需執行22s.而普通表在tempdb中也只需27s均大大優于普通表中執行情況.

感興趣的朋友亦可在執行過程中觀察日志相關的性能技術器的運行情況如(Log Bytes Flusged /sec 等)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阳信县| 晋城| 清涧县| 固安县| 西盟| 修水县| 南汇区| 融水| 邯郸市| 镇雄县| 邯郸市| 策勒县| 赣榆县| 崇信县| 永和县| 延寿县| 抚远县| 永康市| 瑞丽市| 宜宾市| 洪江市| 蚌埠市| 瑞丽市| 涟水县| 华蓥市| 乌恰县| 安丘市| 玛多县| 图们市| 麦盖提县| 竹北市| 星座| 库伦旗| 和顺县| 辽阳市| 沈阳市| 榕江县| 正蓝旗| 乐山市| 苗栗市| 临汾市|