sql server - Stored procedure is very slow -


i'm not database specialist , want ask issue have.

there's ms sql server 2008 r2 stored procedure slow. how work?

1) stor. proc. takes 2 input parameters: begindate , enddate (datetime) 2) temporary table created using: declare @temp table (columns) 3) insert @temp select columns huge_view conditions1 4) insert @temp select columns huge_view conditions2 5) select columns @temp group columns order columns 

the huge_view has inner, left , right joins.

i know it's hard without taking @ real code, maybe give guidelines.

  1. check if performance slow when run on sql server or slow when execute client machine. if slow client machine, network issue.
  2. check how data view has.
  3. check if tables have primary key, foreign key , constraints ever applicable. can dramatically increase performance of joins.
  4. run database tuning advisor find out additional indexes , statistics can create.

Comments