Reply to Re: Optimizing Stored Procedure with Datetime parameter

Your name:

Reply:


Posted by Gert-Jan Strik on 11/17/05 23:55

Paul,

Your stored procedure could benefit from parameter sniffing if you
change the local variable into a parameter, as in:

CREATE PROCEDURE MyProcedure (@createddatelower datetime) AS
...
WHERE eventdate > dateadd(day,-7,@createddatelower)
...

EXEC MyProcedure '20051115'

HTH,
Gert-Jan



paulmac106 wrote:
>
> Hi,
>
> When I pass a date time parameter the stored procedure takes about 45
> seconds, when I hard code the parameter it returns in 1 second. How can
> I rewrite my stored procedure?
>
> @createddatelower datetime
>
> WHERE dbo.tblCaseHistory.eventdate > dateadd(d,-7,@createddatelower )
> AND dbo.tblCaseHistory.eventdate < dateadd(d,-6,@createddatelower ) (45
> seconds)
>
> vs.
>
> WHERE dbo.tblCaseHistory.eventdate > dateadd(d,-7,'11/15/05') AND
> dbo.tblCaseHistory.eventdate < dateadd(d,-6,'11/15/05') (1 second)
>
> thanks for your help,
> Paul

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация