mssql2012存储过程执行SQL和直接执行sql效率的疑问 20
数据库MSSQL2012sql语句:select*fromLogLogin存储过程代码:SETANSI_NULLSONGOSETQUOTED_IDENTIFIERONGO...
数据库 MSSQL2012
sql语句:select * from LogLogin
存储过程代码:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter PROCEDURE P_TB_Log
AS
declare @sql nvarchar(4000)
BEGIN
SET NOCOUNT ON;
set @sql = 'select * from u8_LogLogin'
exec(@sql)
END
GO
该表的数据量100万+
直接执行sql语句用时7秒
执行存储过程跑了2分钟还没出来结果
请教理论上存储过程应该要比直接执行sql语句要快 为什么实际上却慢呢
哦 上面写错了
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter PROCEDURE P_TB_Log
AS
declare @sql nvarchar(4000)
BEGIN
SET NOCOUNT ON;
set @sql = 'select * from LogLogin'
exec(@sql)
END
GO 展开
sql语句:select * from LogLogin
存储过程代码:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter PROCEDURE P_TB_Log
AS
declare @sql nvarchar(4000)
BEGIN
SET NOCOUNT ON;
set @sql = 'select * from u8_LogLogin'
exec(@sql)
END
GO
该表的数据量100万+
直接执行sql语句用时7秒
执行存储过程跑了2分钟还没出来结果
请教理论上存储过程应该要比直接执行sql语句要快 为什么实际上却慢呢
哦 上面写错了
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter PROCEDURE P_TB_Log
AS
declare @sql nvarchar(4000)
BEGIN
SET NOCOUNT ON;
set @sql = 'select * from LogLogin'
exec(@sql)
END
GO 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询