Click here to Skip to main content
16,008,942 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi,

i have a updated query in stored proc.It runs fastly for a while in application ie within a second it will execute,after some few minutes it will take around 40 seconds.Again if we refresh the application and use,it will run fastly.

query as below,

SQL
ALTER PROCEDURE [dbo].[UpdateSatckWithBookID] 

@movie_ID int,
@screen_ID tinyint,
@class_ID  tinyint,
@movie_ShowDate smalldatetime,
@show_ID tinyint,
@row_No smallint,
@col_No smallint,
@is_Available bit,
@is_Counter char(10),
@book_DateTime smalldatetime,
@book_IPAddress varchar(15)

as
set nocount on
set transaction isolation level serializable
begin transaction


Update movie_Show_Stack set is_Available=@is_Available,is_Counter=@is_Counter,book_DateTime=convert(smalldatetime,@book_DateTime,103),book_IPAddress=@book_IPAddress  where row_no=@row_No and col_No = @col_No and screen_id=@screen_ID  and class_id=@class_ID  and Show_ID=@show_ID and Movie_ID=@movie_ID and movie_ShowDate =convert(smalldatetime,@movie_ShowDate,103)


if(@@error<>0)
begin
 rollback transaction
 return -1
end
else
begin
 commit transaction
 return 1
end


please reply with an example
Posted
Updated 20-Dec-11 18:10pm
v3
Comments
Karthik Harve 21-Dec-11 0:09am    
[Edit] pre tags added.
Amir Mahfoozi 21-Dec-11 0:15am    
If many people use this stored procedure at the same time its because of isolated transactions. but if no one used them at that time then I guess that SQL Server was on its maintenance stage or may be it was updating its indexes information.
ks ravi 21-Dec-11 0:28am    
thanks for reply.i would like give some information that one one user using and not using indexes.please reply.
[no name] 21-Dec-11 1:54am    
any trigger's are executed on update?

Possibly a parameter sniffing issue ? One way to check this would be to declare a set of local variables that match your parameters, set them to the parameters and then use the local vars rather than the parameters in your update statement
 
Share this answer
 
Make sure that movie_Show_Stack has proper index on below columns

row_no
col_No
screen_id
class_id
Show_ID
Movie_ID
movie_ShowDate
 
Share this answer
 
Hi,

as this is the most restrictive isolation level , it will try to acquire lock on your table rows range. so it may so happen it takes some time for that. but check in profiler if anyother query is running on background or not.

also check if you have fresh installation of SQL server ?

thanks
-amit.
 
Share this answer
 
There are several possibilities:

As Amir already pointed out one reason could interfering locks etc. Use SSMS to check different kinds conflicts: Monitoring with SQL Server Management Studio[^]

If there are no locking issues and you wrote that refreshing application helps, it also sounds that the problem may be on the calling side. Check if the bottleneck is there and that your connection settings including connection pool are correct.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900