SQLServerManagementStudio中的性能测试
如何在sql server management studio中插入用于性能测试的示例数据要填充大型表,可以使用以下方法设置行数:SQLServerManagementStudio中的性能测试,sql,sql-server,Sql,Sql Server,如何在sql server management studio中插入用于性能测试的示例数据要填充大型表,可以使用以下方法设置行数: CREATE Table Persons ( Id int identity primary key, Name nvarchar(50), Country nvarchar(50) ) Declare @Id int set nocount on; declare @start datetime = getutcdate(); de
CREATE Table Persons
(
Id int identity primary key,
Name nvarchar(50),
Country nvarchar(50)
)
Declare @Id int
set nocount on;
declare @start datetime = getutcdate();
declare @i int = 0;
Set @Id = 1
While @Id <= 120000
Begin
Insert Into Persons values ('Name - ' + CAST(@Id as nvarchar(10)),
'Country - ' + CAST(@Id as nvarchar(10)) + ' name')
Print @Id
Set @Id = @Id + 1
END
SELECT datediff(ms, @start, getutcdate());
您可以使用许多技术,下面列出了其中的几个
设置统计时间代码>在插入查询上方
执行计划
并在同一查询选项卡中执行现有的和优化的两个查询(按Ctrl+N),并查看执行计划中哪个查询执行的百分比更高PRINT GETDATE()
,并去掉两个时间的差异可能还有很多其他技术,我通常很少使用这些技术。您能更清楚、更具体一些吗?当我们将数据插入sql server表时,我们可以在执行查询时测试性能。我的问题是,这项任务有哪些可用的技术?看一看嘿,快点,谢谢你的回答。我有一个问题,性能测试在哪里?@KMS ooops,我忘了添加测量值。请看我的最新答案非常感谢SetUp@KMS我很高兴帮助你!:)我运行你的代码。但是它有以下错误-必须声明标量变量“@start”。非常感谢你
SET STATISTICS TIME ON
SET STATISTICS IO ON
GO
Declare @Id int
set nocount on;
declare @i int = 0;
Set @Id = 1
While @Id <= 120000
Begin
Insert Into Persons values ('Name - ' + CAST(@Id as nvarchar(10)),
'Country - ' + CAST(@Id as nvarchar(10)) + ' name')
Print @Id
Set @Id = @Id + 1
END
SET STATISTICS IO OFF
SET STATISTICS TIME OFF
GO