Click here to Skip to main content
15,887,683 members
Home / Discussions / Database
   

Database

 
AnswerRe: INSERT - SELECT QUERY Help Needed. Pin
Mycroft Holmes23-May-13 11:15
professionalMycroft Holmes23-May-13 11:15 
QuestionHey need help of adding data T__T Pin
Al Arcilla23-May-13 4:54
Al Arcilla23-May-13 4:54 
AnswerRe: Hey need help of adding data T__T Pin
Simon_Whale23-May-13 5:16
Simon_Whale23-May-13 5:16 
AnswerRe: Hey need help of adding data T__T Pin
Eddy Vluggen24-May-13 0:23
professionalEddy Vluggen24-May-13 0:23 
AnswerRe: Hey need help of adding data T__T Pin
Al Arcilla26-May-13 3:50
Al Arcilla26-May-13 3:50 
Questiondisributed database (in one computer(at sql 2008)/two server)؟? Pin
22majid2222-May-13 19:44
22majid2222-May-13 19:44 
AnswerRe: disributed database (in one computer(at sql 2008)/two server)؟? Pin
Mycroft Holmes22-May-13 22:07
professionalMycroft Holmes22-May-13 22:07 
QuestionSelect in SP slower than non-SP ? Pin
Saxet22-May-13 7:16
Saxet22-May-13 7:16 
I have this SQL Server 2012 trivial stored procedure:
SQL
CREATE PROCEDURE usp_SelectCompany
AS
BEGIN
	SET NOCOUNT ON
	SELECT * FROM Company
END

and in a SSMS window, I execute this commands below to discover my SP is much slower than directly executing SELECT * from Company, even after the SP is run once to compile it.
SQL
-- create temp table so SSMS results output doesn't interfere too much with with query execution time 
SELECT * INTO #Company FROM Company WHERE 1=0

-- run the SP once to ensure that is is compiled
INSERT #Company EXEC usp_SelectCompany

PRINT 'Start Time:  ' + cast(sysdatetime() as varchar)
INSERT #Company EXEC usp_SelectCompany
PRINT 'SP Time:     ' + cast(sysdatetime() as varchar)
INSERT #Company SELECT * FROM Company
PRINT 'Select Time: ' + cast(sysdatetime() as varchar)

Here is the output:
(0 row(s) affected)

(127733 row(s) affected)
Start Time:  2013-05-22 11:56:57.7208741

(127733 row(s) affected)
SP Time:     2013-05-22 11:57:03.2067327

(127733 row(s) affected)
Select Time: 2013-05-22 11:57:04.0015524

I note that the SP executes in 5.4858586 seconds, and the direct "select" statement only takes 0.7948197 seconds, or about 7 times slower.

Can anyone explain this behavior?
QuestionRe: Select in SP slower than non-SP ? Pin
Eddy Vluggen22-May-13 7:36
professionalEddy Vluggen22-May-13 7:36 
AnswerRe: Select in SP slower than non-SP ? Pin
Saxet22-May-13 8:03
Saxet22-May-13 8:03 
GeneralRe: Select in SP slower than non-SP ? Pin
Eddy Vluggen22-May-13 8:20
professionalEddy Vluggen22-May-13 8:20 
GeneralRe: Select in SP slower than non-SP ? Pin
PIEBALDconsult22-May-13 14:54
mvePIEBALDconsult22-May-13 14:54 
GeneralRe: Select in SP slower than non-SP ? Pin
Saxet23-May-13 3:49
Saxet23-May-13 3:49 
GeneralRe: Select in SP slower than non-SP ? Pin
PIEBALDconsult23-May-13 13:42
mvePIEBALDconsult23-May-13 13:42 
AnswerRe: Select in SP slower than non-SP ? Pin
Bernhard Hiller22-May-13 21:28
Bernhard Hiller22-May-13 21:28 
QuestionData Clashes Pin
Bram van Kampen21-May-13 15:04
Bram van Kampen21-May-13 15:04 
AnswerRe: Data Clashes Pin
David Mujica22-May-13 2:26
David Mujica22-May-13 2:26 
GeneralRe: Data Clashes Pin
Bram van Kampen23-May-13 15:55
Bram van Kampen23-May-13 15:55 
GeneralTransactions and Identity Pin
David Mujica29-May-13 2:27
David Mujica29-May-13 2:27 
QuestionStored Procedures SQL Server Pin
damokk21-May-13 1:11
damokk21-May-13 1:11 
AnswerRe: Stored Procedures SQL Server Pin
scottgp21-May-13 2:37
professionalscottgp21-May-13 2:37 
AnswerRe: Stored Procedures SQL Server Pin
Corporal Agarn21-May-13 2:58
professionalCorporal Agarn21-May-13 2:58 
GeneralRe: Stored Procedures SQL Server Pin
damokk21-May-13 4:14
damokk21-May-13 4:14 
AnswerRe: Stored Procedures SQL Server Pin
Mycroft Holmes21-May-13 3:19
professionalMycroft Holmes21-May-13 3:19 
GeneralRe: Stored Procedures SQL Server Pin
damokk21-May-13 4:15
damokk21-May-13 4:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.