成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

自動管理分區(qū)

表分區(qū)的一個好處:能夠避免Deadlock,分區(qū)之間是相互獨立的,對一個分區(qū)加X鎖,不會對其他分區(qū)產生contention。

創(chuàng)新互聯(lián)主營鄱陽網站建設的網絡公司,主營網站建設方案,成都app軟件開發(fā),鄱陽h5小程序制作搭建,鄱陽網站營銷推廣歡迎鄱陽等地區(qū)企業(yè)咨詢

在項目中,有如下 Partition Function 和 Partition Scheme

自動管理分區(qū)

CREATE PARTITION FUNCTION [funcPartition_int_DataSourceID](int) 
AS RANGE LEFT FOR VALUES (1, 2, 3)CREATE PARTITION SCHEME [schePartition_int_DataSourceID] AS PARTITION [funcPartition_DataSourceID] TO ([PRIMARY], [PRIMARY], [PRIMARY], [PRIMARY])create table dbo.dt_test
(
...More column definition

DataSourceID int)on [schePartition_int_DataSourceID](DataSourceID)

自動管理分區(qū)

查看ETL的execution log,有時會發(fā)現 Deadlock Issue,對相關package Troubleshooting發(fā)現,發(fā)生deadlock的root cause是:同時更新表的兩條語句產生contention,導致deadlock。仔細check代碼,更新的兩條查詢語句都使用Partition Column(DataSourceID) 作為過濾條件。我推測,可能是這兩個DataSourceID位于同一個Partition。

1,驗證boundary value

select prv.function_id,pf.name,pf.boundary_value_on_right,prv.value as BoundaryValuefrom sys.partition_range_values prvinner join sys.partition_functions pf    on prv.function_id=pf.function_idwhere pf.name='funcPartition_int_DataSourceID'

BoundaryValue的值小于當前 DataSourceID的最大值,產生 contention的兩個DataSourceID 在最右邊的partition中。

隨著項目數據的增加和人員的更替,缺少合理的管理計劃,導致額外增加的DataSourceID都被分配到同一個partition中。
2,創(chuàng)建Job,自動分區(qū)

最佳實踐,如果一個partition是non-empty,那么split range會導致data movement,這可能是一個非常耗費IO的一個process,為了避免extensive data movement,最好是預留一個empty partition,每次都從empty partition 中split range。

自動管理分區(qū)

use db_studygodeclare @CurrentMaxBoundaryValue intdeclare @ExistingMaxDataSourceID intdeclare @BoudaryValue intselect @ExistingMaxDataSourceID = max(dds.DataSourceID)from dbo.dt_DataSource dds with(nolock)select @CurrentMaxBoundaryValue= max(cast(prv.value as int))from sys.partition_functions pf 
inner join sys.partition_range_values prv    on pf.function_id=prv.function_idwhere pf.name='funcPartition_int_DataSourceID'-- add new boundary valueif @CurrentMaxBoundaryValue<@ExistingMaxDataSourceID+1begin
    set @BoudaryValue=@CurrentMaxBoundaryValue+1

    DECLARE @SQL NVARCHAR(MAX)=N'ALTER PARTITION SCHEME [schePartition_int_DataSourceID]
NEXT USED [PRIMARY]
ALTER PARTITION FUNCTION [funcPartition_int_DataSourceID]()
SPLIT RANGE ('
    declare @ExecSql nvarchar(max)    set @ExecSql=''

    while @BoudaryValue<=@ExistingMaxDataSourceID+1
    BEGIN
        
        SELECT @ExecSql = @SQL+ cast(@BoudaryValue as varchar(10))+ N')'
        EXEC(@ExecSql)        set @BoudaryValue=@BoudaryValue+1
    endend

自動管理分區(qū)

本例將分區(qū)全部存放在Primary FileGroup, 如果需要將不同的Partition存儲在不同的FileGroup,那么可以增加Create filegroup的代碼。

3,在Job執(zhí)行時,Issue an error

Executed as user: NT SERVICE\SQLSERVERAGENT. UNKNOWN TOKEN failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations. [SQLSTATE 42000] (Error 1934).  The step failed.

QUOTED_IDENTIFIER設置錯誤,添加下面的script,即可

SET QUOTED_IDENTIFIER  ON

參考:SET QUOTED_IDENTIFIER (Transact-SQL)

  1. SET QUOTED_IDENTIFIER must be ON when you are creating or changing indexes on computed columns or indexed views. If SET QUOTED_IDENTIFIER is OFF, CREATE, UPDATE, INSERT, and DELETE statements on tables with indexes on computed columns or indexed views will fail.

  2. SET QUOTED_IDENTIFIER must be ON when you are creating a filtered index.

  3. SET QUOTED_IDENTIFIER must be ON when you invoke XML data type methods.

分享題目:自動管理分區(qū)
瀏覽路徑:http://jinyejixie.com/article40/iihhho.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供網站制作、網頁設計公司企業(yè)建站、云服務器網站導航、定制開發(fā)

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務器托管
栖霞市| 桂平市| 淄博市| 沙湾县| 高青县| 新田县| 怀宁县| 成安县| 定安县| 泰宁县| 南平市| 林芝县| 南昌县| 聂拉木县| 民权县| 怀安县| 内黄县| 长阳| 金溪县| 沙坪坝区| 襄垣县| 扎鲁特旗| 莱州市| 漳平市| 红原县| 贵州省| 克拉玛依市| 茶陵县| 攀枝花市| 容城县| 玛纳斯县| 长乐市| 河津市| 宁夏| 黎平县| 炉霍县| 博白县| 辽阳市| 中卫市| 齐河县| 尚义县|