pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

UniqueIdentifier 聚集索引上的 NewSequentialId

NewSequentialId on UniqueIdentifier Clustered Index(UniqueIdentifier 聚集索引上的 NewSequentialId)
本文介紹了UniqueIdentifier 聚集索引上的 NewSequentialId的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在為我公司正在啟動的新數(shù)據(jù)庫制定數(shù)據(jù)庫標準.我們試圖定義的一件事是與 UniqueIdentifiers 相關(guān)的主鍵和聚集索引規(guī)則.

I am working on database standards for a new database my company is starting. One of the things we are trying to define is Primary Key and Clustered Index rules in relation to UniqueIdentifiers.

(注意:我不想討論使用 UniqueIdentifier 作為主鍵或聚集索引的利弊.網(wǎng)絡(luò)上有大量關(guān)于此的信息.這不是 那個討論.)

(NOTE: I do not want a discussion on the pros and cons of using a UniqueIdentifier as a primary key or clustered index. There is a ton of info on the web about that. This is not that discussion.)

所以這是讓我擔心的場景:

So here is the scenario that has me worried:

假設(shè)我有一個表,它有一個 UniqueIdentifier 作為聚集索引和主鍵.讓我們稱之為可樂.我將 ColA 的默認值設(shè)置為 NewSequentialId().

Say I have a table with a UniqueIdentifier as the clustered index and primary key. Lets call it ColA. I set the default value for ColA to be NewSequentialId().

使用 NewSequentialId() 我插入三個連續(xù)的行:

Using that NewSequentialId() I insert three sequential rows:

{72586AA4-D2C3-440D-A9FE-CC7988DDF065}
{72586AA4-D2C3-440D-A9FE-CC7988DDF066}
{72586AA4-D2C3-440D-A9FE-CC7988DDF067}

{72586AA4-D2C3-440D-A9FE-CC7988DDF065}
{72586AA4-D2C3-440D-A9FE-CC7988DDF066}
{72586AA4-D2C3-440D-A9FE-CC7988DDF067}

然后我重新啟動我的服務(wù)器.NewSequentialId 的文檔 說重新啟動 Windows 后,GUID 可以啟動再次來自較低的范圍,但仍然是全球唯一的."

Then I reboot my server. The docs for NewSequentialId say that "After restarting Windows, the GUID can start again from a lower range, but is still globally unique."

所以下一個起點可以低于上一個范圍.

So the next starting point can be lower than the previous range.

所以在重新啟動后,我又插入了 3 個值:

So after the restart, I insert 3 more values:

{35729A0C-F016-4645-ABA9-B098D2003E64}
{35729A0C-F016-4645-ABA9-B098D2003E65}
{35729A0C-F016-4645-ABA9-B098D2003E66}

{35729A0C-F016-4645-ABA9-B098D2003E64}
{35729A0C-F016-4645-ABA9-B098D2003E65}
{35729A0C-F016-4645-ABA9-B098D2003E66}

(我不確定該 guid 在數(shù)據(jù)庫中的確切表示方式,但讓我們假設(shè),因為這個 guid 以 3 開頭,而前一個以 7 開頭,所以 3 個比 7 個小".)

(I am not sure exactly how the guid is represented in the database, but lets assume since this one starts with 3 and the previous ones started with 7 that the 3 ones are "smaller" than the 7 ones.)

當您在聚集索引中間執(zhí)行插入操作時,必須重新映射索引.(至少我的 DBA 是這么告訴我的.)而且每次我重新啟動時,我都會冒著讓我的新 UniqueIdentifier 范圍正好位于其他先前范圍中間的風險.

When you do an insert that is in the middle of a clustered index, a remapping of the index has to happen. (At least so my DBA has told me.) And every time I reboot I run the risk of having my new UniqueIdentifier range be right in the middle of other previous ranges.

所以我的問題是:由于下一組 UniqueIdentifiers 將小于上一組,所以每次插入都會導(dǎo)致我的聚集索引混洗嗎?

So my question is: Since the next set of UniqueIdentifiers will be smaller than the last set, will every insert cause my clustered index to shuffle?

如果沒有,為什么?SQL Server 知道我在使用 NewSequentialId 嗎?有什么辦法彌補嗎?

And if not, why? Does SQL Server know that I am using NewSequentialId? Does it some how compensate for that?

如果沒有,那么它怎么知道我接下來要插入什么?也許接下來的一百萬次插入將從 3 開始.或者他們可能會從 7 開始.它怎么知道?

If not, then how does it know what I will insert next? Maybe the next million inserts will start with 3. Or maybe they will start with 7. How does it know?

或者它不知道并保持一切井然有序.如果是這種情況,那么一次重新啟動可能會嚴重影響性能.(這讓我覺得我需要自己的不受重啟影響的自定義 NewSequentialId.)對嗎?還是有什么我不知道的魔法?

Or does it not know and just keeps everything in order. If that is the case then one reboot could massively affect performance. (Which makes me think I need my own custom NewSequentialId that is not affected by reboots.) Is that correct? Or is there some magic I am not aware of?

在我的標準中強烈不鼓勵將 GUID 作為聚集索引.正如我上面所說,有很多原因表明這是一個壞主意.我想知道這是否是另一個原因.

GUID as a clustered index is strongly discouraged in my standard. As I said above, there are many reasons that this is a bad idea. I am trying to find out if this is another reason why.

推薦答案

通常,您將使用適當?shù)?FILL FACTOR 創(chuàng)建索引,以便在所有頁面中為這種情況留出空白空間.也就是說,一旦空白空間被填滿,聚集索引就會重新排序.

Normally you will create your indexes with an appropriate FILL FACTOR to leave empty space in all your pages for just such a scenario. That being said, the clustered index does get reordered once the empty space is filled.

我知道您不想討論使用 GUID 作為聚集鍵,但這是不推薦做法的原因之一.

I know you don't want to discuss using GUID as a clustered key, but this is one of the reasons that it's not a recommended practice.

將會發(fā)生的情況是,您將有越來越多的頁面拆分,這將在您不斷插入行時導(dǎo)致非常高的碎片水平,并且您將需要以更高的頻率重建索引以保持性能線.

What will happen is that you will have an increasing volume of page splits, which will lead to a very high level of fragmentation as you keep inserting rows, and you will need to rebuild your index at a higher frequency to keep performance in line.

有關(guān)該主題的完整處理,沒有比

For a full treatment on the topic, there's no better source than


Tripp 的
博客

附帶說明,當您考慮創(chuàng)建自己的 NewSequentialID 創(chuàng)建函數(shù)時,您可能遇到了設(shè)計問題,應(yīng)該重新考慮您的計劃.

As a side note, when you are considering creating your own NewSequentialID creation function, you probably have a design issue and should reconsider your plan.

這篇關(guān)于UniqueIdentifier 聚集索引上的 NewSequentialId的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

What SQL Server Datatype Should I Use To Store A Byte[](我應(yīng)該使用什么 SQL Server 數(shù)據(jù)類型來存儲字節(jié) [])
Interpreting type codes in sys.objects in SQL Server(解釋 SQL Server 中 sys.objects 中的類型代碼)
Typeorm .loadRelationCountAndMap returns zeros(Typeorm .loadRelationCountAndMap 返回零)
MS SQL: Should ISDATE() Return quot;1quot; when Cannot Cast as Date?(MS SQL:ISDATE() 是否應(yīng)該返回“1?什么時候不能投射為日期?)
Converting the name of a day to its integer representation(將一天的名稱轉(zhuǎn)換為其整數(shù)表示)
How to convert nvarchar m/d/yy to mm/dd/yyyy in SQL Server?(如何在 SQL Server 中將 nvarchar m/d/yy 轉(zhuǎn)換為 mm/dd/yyyy?)
主站蜘蛛池模板: 上海网站建设-上海网站制作-上海网站设计-上海做网站公司-咏熠软件 | 大流量卧式砂磨机_强力分散机_双行星双动力混合机_同心双轴搅拌机-莱州市龙跃化工机械有限公司 | 自恢复保险丝_贴片保险丝_力特保险丝_Littelfuse_可恢复保险丝供应商-秦晋电子 | 宜兴市恺瑞德环保科技有限公司| 航空铝型材,7系铝型材挤压,硬质阳*氧化-余润铝制品 | 上海阳光泵业制造有限公司 -【官方网站】 | 下水道疏通_管道疏通_马桶疏通_附近疏通电话- 立刻通 | 精密五金加工厂-CNC数控车床加工_冲压件|蜗杆|螺杆加工「新锦泰」 | 衬塑设备,衬四氟设备,衬氟设备-淄博鲲鹏防腐设备有限公司 | 箱式破碎机_移动方箱式破碎机/价格/厂家_【华盛铭重工】 | 户外-组合-幼儿园-不锈钢-儿童-滑滑梯-床-玩具-淘气堡-厂家-价格 | 国产离子色谱仪,红外分光测油仪,自动烟尘烟气测试仪-青岛埃仑通用科技有限公司 | 电子巡更系统-巡检管理系统-智能巡检【金万码】 | 包装机传感器-搅拌站传感器-山东称重传感器厂家-济南泰钦电气 | 培训无忧网-教育培训咨询招生第三方平台 | 吉祥新世纪铝塑板_生产铝塑板厂家_铝塑板生产厂家_临沂市兴达铝塑装饰材料有限公司 | CE认证_FCC认证_CCC认证_MFI认证_UN38.3认证-微测检测 CNAS实验室 | 高压贴片电容|贴片安规电容|三端滤波器|风华电容代理南京南山 | 济南玻璃安装_济南玻璃门_济南感应门_济南玻璃隔断_济南玻璃门维修_济南镜片安装_济南肯德基门_济南高隔间-济南凯轩鹏宇玻璃有限公司 | 英思科GTD-3000EX(美国英思科气体检测仪MX4MX6)百科-北京嘉华众信科技有限公司 | 盘装氧量分析仪-防爆壁挂氧化锆分析仪-安徽吉帆仪表有限公司 | 杭州月嫂技术培训服务公司-催乳师培训中心报名费用-产后康复师培训机构-杭州优贝姆健康管理有限公司 | 无水硫酸铝,硫酸铝厂家-淄博双赢新材料科技有限公司 | 衡阳耐适防护科技有限公司——威仕盾焊接防护用品官网/焊工手套/焊接防护服/皮革防护手套 | 软文发布-新闻发布推广平台-代写文章-网络广告营销-自助发稿公司媒介星 | 大立教育官网-一级建造师培训-二级建造师培训-造价工程师-安全工程师-监理工程师考试培训 | 伺服电机_直流伺服_交流伺服_DD马达_拓达官方网站 | nalgene洗瓶,nalgene量筒,nalgene窄口瓶,nalgene放水口大瓶,浙江省nalgene代理-杭州雷琪实验器材有限公司 | led全彩屏-室内|学校|展厅|p3|户外|会议室|圆柱|p2.5LED显示屏-LED显示屏价格-LED互动地砖屏_蕙宇屏科技 | 南京PVC快速门厂家南京快速卷帘门_南京pvc快速门_世界500强企业国内供应商_南京美高门业 | 成都顶呱呱信息技术有限公司-贷款_个人贷款_银行贷款在线申请 - 成都贷款公司 | 生物风-销售载体,基因,质粒,ATCC细胞,ATCC菌株等,欢迎购买-百风生物 | 济南办公室装修-厂房装修-商铺装修-工装公司-山东鲁工装饰设计 | 企业管理培训,企业培训公开课,企业内训课程,企业培训师 - 名课堂企业管理培训网 | 阿尔法-MDR2000无转子硫化仪-STM566 SATRA拉力试验机-青岛阿尔法仪器有限公司 | 福兰德PVC地板|PVC塑胶地板|PVC运动地板|PVC商用地板-中国弹性地板系统专业解决方案领先供应商! 福建成考网-福建成人高考网 | 阳光1号桔柚_无核沃柑_柑橘新品种枝条苗木批发 - 苧金网 | 蓝莓施肥机,智能施肥机,自动施肥机,水肥一体化项目,水肥一体机厂家,小型施肥机,圣大节水,滴灌施工方案,山东圣大节水科技有限公司官网17864474793 | 贴板式电磁阀-不锈钢-气动上展式放料阀-上海弗雷西阀门有限公司 工业机械三维动画制作 环保设备原理三维演示动画 自动化装配产线三维动画制作公司-南京燃动数字 | 东莞螺杆空压机_永磁变频空压机_节能空压机_空压机工厂批发_深圳螺杆空压机_广州螺杆空压机_东莞空压机_空压机批发_东莞空压机工厂批发_东莞市文颖设备科技有限公司 | 手持式3d激光扫描仪-便携式三维立体扫描仪-北京福禄克斯 |