插入是否可能使用并行性?

插入是否可能使用并行性?

在什么情况下插入一条简单记录(表有大约 10 列,其中两列是 xml)可以使用并行性?

CREATE TABLE [dbo].[PackageSessions](
    [PackageSessionId] [int] IDENTITY(1,1) NOT NULL,
    [PackageId] [int] NOT NULL,
    [UserId] [int] NOT NULL,
    [StartDateTime] [datetime] NULL,
    [StopDateTime] [datetime] NULL,
    [Score] [float] NOT NULL,
    [ScoreMax] [float] NOT NULL,
    [CompletionStatus] [int] NOT NULL,
    [ReviewPlayerContextId] [int] NOT NULL,
    [PlayerContextId] [int] NOT NULL,
    [ReducedScore] [float] NOT NULL,
    [ReducedScoreMax] [float] NOT NULL,
    [PackageSnapShot] [xml] NULL,
    [InterfaceLanguageId] [int] NOT NULL,
    [Data] [xml] NULL,
    [PackageSessionLanguageId] [int] NOT NULL,
 CONSTRAINT [PackageSessions_PK] PRIMARY KEY CLUSTERED 
(
    [PackageSessionId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

答案1

插入一条简单直接的记录,例如:

INSERT INTO PackageSessions VALUES (1, 2, 3, NULL, NULL, 1.0, 2.0, 3, 4, 5, 6.0, 7.0, NULL, 1, NULL, 2)

永远不会并行化。SQL 服务器会检测哪些作业可以拆分,比如说,如果您正在对表进行更新,它可能会将表分成两半,并将每一半分配给两个不同的处理器。如果作业不能相当容易地拆分,它将在不并行化的情况下运行。

(Schema-Nazi 注:表名应该是单数)

相关内容