Simple way to retrieve the query execution time @qry varchar(100), @StartLoc int @StartTime datetime,@EndTime
SETdatetime @StartTime = CURRENT_TIMESTAMP;-- **********QUERY TO BE CHECKED *************SELECT *FROM snippetkey_for_testing.dbo.snippet_config_fieldrules-- *****************************************SET @EndTime = CURRENT_TIMESTAMPSELECT DATEDIFF(ms, @StartTime, @EndTime)
declare
DECLARE
SETdatetime @StartTime = CURRENT_TIMESTAMP;-- **********QUERY TO BE CHECKED *************SELECT *FROM snippetkey_for_testing.dbo.snippet_config_fieldrules-- *****************************************SET @EndTime = CURRENT_TIMESTAMPSELECT DATEDIFF(ms, @StartTime, @EndTime)
Improving Performance with SQL Server 2008 Indexed Views
SELECTCREATE VIEW Vdiscount2 WITH SCHEMABINDING AS SUM(UnitPrice*OrderQty)AS SumPrice,SUM(UnitPrice*OrderQty*(1.00-UnitPriceDiscount))AS SumDiscountPrice,SUM(UnitPrice*OrderQty*UnitPriceDiscount)AS SumDiscountPrice2,COUNT_BIG(*) AS Count, ProductIDFROM Sales.SalesOrderDetailGROUP BY ProductID

Ex:
SELECTCREATE VIEW Vdiscount2 WITH SCHEMABINDING AS SUM(UnitPrice*OrderQty)AS SumPrice,SUM(UnitPrice*OrderQty*(1.00-UnitPriceDiscount))AS SumDiscountPrice,SUM(UnitPrice*OrderQty*UnitPriceDiscount)AS SumDiscountPrice2,COUNT_BIG(*) AS Count, ProductIDFROM Sales.SalesOrderDetailGROUP BY ProductID
Why do indexed views have to be defined WITH SCHEMABINDING?
sp_who VS Sp_Who2
sp_who is used to list all the users connected to sql serverIt will list out the current process id, login user name, process through which the user gets connected, connected time, duration, Details database accessed by the user, login user role.Difference between spwho and spwho2:Both will perform the same operation, sp_who2 will give additional performance related information likeCPU
Disk
SPID
There time I/Ois an alternative way to retrieve the result set. We can achieve it by accessing the system tables too,select* from master.dbo.syslogins
sp_who is used to list all the users connected to sql serverIt will list out the current process id, login user name, process through which the user gets connected, connected time, duration, Details database accessed by the user, login user role.Difference between spwho and spwho2:Both will perform the same operation, sp_who2 will give additional performance related information likeCPU
Disk
SPID
There time I/Ois an alternative way to retrieve the result set. We can achieve it by accessing the system tables too,select* from master.dbo.syslogins
A. So that both of the following conditions are met:
- All objects the view references are unambiguously identified using schemaname.objectname, regardless of which user is accessing the view.
- The objects referred to in the view definition can't be altered in a way that would make the view definition illegal or force SQL Server to re-create the index on the view.
declare
DECLARE
Comments
Post a Comment