模糊的标题我知道。
目前,我的数据库中有 16,000 行。这是在开发过程中创建的,我现在想删除所有这些行,以便我可以重新开始(所以我没有重复的数据)。
该数据库位于 SQL Azure 上。
如果我运行选择查询
SELECT [Guid]
,[IssueNumber]
,[Severity]
,[PainIndex]
,[Status]
,[Month]
,[Year]
,[DateCreated]
,[Region]
,[IncidentStart]
,[IncidentEnd]
,[SRCount]
,[AggravatingFactors]
,[AggravatingFactorDescription]
FROM [dbo].[WeeklyGSFEntity]
GO
这将返回所有行,SSMS 说这需要 49 秒。
如果我试图放下桌子,这会持续 5 分钟以上。
DROP TABLE [dbo].[WeeklyGSFEntity]
GO
/****** Object: Table [dbo].[WeeklyGSFEntity] Script Date: 10/01/2013 09:46:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[WeeklyGSFEntity](
[Guid] [uniqueidentifier] NOT NULL,
[IssueNumber] [int] NULL,
[Severity] [int] NULL,
[PainIndex] [nchar](1) NULL,
[Status] [nvarchar](255) NULL,
[Month] [int] NULL,
[Year] [int] NULL,
[DateCreated] [datetime] NULL,
[Region] [nvarchar](255) NULL,
[IncidentStart] [datetime] NULL,
[IncidentEnd] [datetime] NULL,
[SRCount] [int] NULL,
[AggravatingFactors] [nvarchar](255) NULL,
[AggravatingFactorDescription] [nvarchar](max) NULL,
PRIMARY KEY CLUSTERED
(
[Guid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
GO
如果我尝试删除每一行,这也需要 5 分钟以上。
DELETE
FROM [dbo].[WeeklyGSFEntity]
GO
我做错了什么还是只是因为这是大数据而我不耐烦了?
更新:
删除整个数据库大约需要 25 秒。
导入 22,000 行(大致相同的 16,000 多行)localdb\v11.0
需要 6 秒。我知道这是本地的,但本地开发服务器肯定比 Azure 慢吗?一定...
更新第二个:
重新创建数据库并重新创建模式(使用(Fluent)NHibernate),然后插入大约 20,000 行需要 2 分 6 秒。所有单元测试均通过。有什么我可以回头看的吗?