简体   繁体   English

分区图表 - 分区切换失败

[英]Partitioned Graph table - Partition Switch failed

I am trying and partitioning to an existing SQL Server Graph table (node).我正在尝试分区到现有的 SQL Server 图形表(节点)。 The table is very large and is taking long time for deletes etc, so hoping to use partitioning to improve the performance.该表非常大,删除等需要很长时间,因此希望使用分区来提高性能。

However, when I add partition and try to SWITCH the data.但是,当我添加分区并尝试切换数据时。 It fails with the below error:它失败并出现以下错误:

Msg 7733, Level 16, State 4, Line 1 'ALTER TABLE SWITCH' statement failed.消息 7733,级别 16,状态 4,第 1 行“ALTER TABLE SWITCH”语句失败。 The table tempdatabase.dbo.graphtable is partitioned while index 'GRAPH_UNIQUE_INDEX_xxxxxxxxx' is not partitioned.表 tempdatabase.dbo.graphtable 已分区,而索引 'GRAPH_UNIQUE_INDEX_xxxxxxxxx' 未分区。

As the index GRAPH_UNIQUE_INDEX_xxxxxxxxx is automatically created, not able to add the partition key it.由于索引 GRAPH_UNIQUE_INDEX_xxxxxxxxx 是自动创建的,所以不能添加分区键吧。

CREATE PARTITION FUNCTION f_partfunction (INT) AS RANGE LEFT 
FOR VALUES (1,100,200,300)
GO

-- Create the partition scheme
CREATE PARTITION SCHEME s_partscheme
AS PARTITION f_partfunction
ALL TO ([PRIMARY]);
GO


CREATE TABLE [dbo].[graphtable](
    PartitionKey INT,
    ID INT,
    EName varchar(100))
 AS NODE  ON s_partscheme (PartitionKey)
go

CREATE TABLE [dbo].[graphtable_test](
    PartitionKey INT,
    ID INT,
    EName varchar(100))
 go

 --Failing Code
 ALTER TABLE [dbo].[graphtable] SWITCH PARTITION 3 TO [dbo].[graphtable_test]

You will have to drop the current index, and then recreate with the index pointing to the partition schema you have.您必须删除当前索引,然后使用指向您拥有的分区架构的索引重新创建。

    CREATE INDEX GRAPH_UNIQUE_INDEX_xxxxxxxxx' ON graphtable
    (
    "Your column"
    )
    INCLUDE (  [Primary Key column]) WITH (DATA_COMPRESSION = PAGE) ON
    [s_partscheme] (PartitionKey)
    GO

In your case l'm guessing its PartitionKey, used as Partition column.在你的情况下,我猜测它的 PartitionKey,用作分区列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM