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

首頁 > 開發 > 綜合 > 正文

行大小計算測試

2024-07-21 02:48:30
字體:
來源:轉載
供稿:網友
行大小計算測試

數據庫中每一行到底占用多少空間,在這里,做個小測試~~~這里只做了堆表的計算,如果包含索引,按照文檔把索引的列也加上就OK啦~

建個測試表,然后用DBCC PAGE打印出Slot的信息

CREATE TABLE TstA( col1 CHAR(5) NULL, col2 CHAR(5) NULL, col3 VARCHAR(5) NULL, col4 VARCHAR(10) NULL, col5 VARCHAR(50) NULL)INSERT INTO TstA (col1,col2,col3,col4,col5) VALUES ('aa1','2222222222','joan2','aoaonfoen','1111111')dbcc ind(TestDB, Object_id('TstA'),-1) 
DBCC PAGE(TestDB,1,11957,1)

然后我就直接把slot的消息貼出來分析吧~~

-------------------------------------------------------------------------------------------------------------------------------------

Slot 0, Offset 0x60, Length 51, DumpStyle BYTE

Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP VARIABLE_COLUMNS

Record Size = 51

Memory Dump @0x0A93C060

00000000: 30000e00 61613120 206a6f61 6e320500 †0...aa1 joan2..

00000010: 00030023 002c0033 00323232 32323232 †...#.,.3.2222222

00000020: 32323261 6f616f6e 666f656e 31313131 †222aoaonfoen1111

00000030: 313131†††††††††††††††††††††††††††††††111

4 8 12 16 20 24 28 32 36 40 44 48 52

30000e0061613120 206a6f61 6e32050000030023 002c0033 00323232 323232332323261 6f616f6e 666f656e31313131313131

1 2 3 4 5 6 7 8 9

1: 固定長度列結束位置

2: 固定長度第一列(col1)

3: 固定長度第二列(col3) --如果之后還有更多的列,繼續往后排

4: 行包含的欄位總數,本例為5

5: 空值維護:計算方式為 2+ (可為空列數+7)/8

6: 每一個可變列的結束位置。長度計算 2 + (可變列列數*2)

7+:變長列的每一個填充列

驗證了這一句話,每行的開銷

  • ix bytes per row for status information and length information.
  • One bit per fixed width column, rounding up to the nearest byte.
  • If there are any variable length columns - four bytes for the first, plus two bytes for each additional variable length column
  • An additional two bytes per row for the offset pointer located at the end of the page.

-----------------------------------------------------------------------------------------------------

經過測試,無論列的順序怎么排,首先會先把定長的字段先排出來,然后再排變長字段~好吧~測試結束

小弟不才~歡迎大家指出不足

參考:

  http://technet.microsoft.com/zh-cn/library/ms189124.aspx

PS:上面2個DBCC 的語法

dbcc ind(dbname|dbid, tbname|tbid,-1)

dbcc page ( {'dbname' | dbid}, filenum, pagenum [, printopt={0|1|2|3} ])

The filenum and pagenum parameters are taken from the page IDs that come from various system tables and appear in DBCC or other system error messages. A page ID of, say, (1:354) has filenum = 1 and pagenum = 354.

The printopt parameter has the following meanings:

0 - print just the page header1 - page header plus per-row hex dumps and a dump of the page slot array (unless its a page that doesn't have one, like allocation bitmaps)2 - page header plus whole page hex dump3 - page header plus detailed per-row interpretation


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 吉林市| 台山市| 临颍县| 当雄县| 蕲春县| 鹿邑县| 平利县| 板桥市| 林周县| 怀来县| 丰台区| 铜川市| 会泽县| 神木县| 钟祥市| 延寿县| 休宁县| 藁城市| 平凉市| 嘉善县| 姚安县| 东海县| 鹤岗市| 黄山市| 云阳县| 东城区| 翁牛特旗| 邵东县| 旺苍县| 玉林市| 福州市| 灌南县| 邮箱| 亚东县| 新宁县| 普定县| 永安市| 涪陵区| 齐齐哈尔市| 太谷县| 马鞍山市|