dbTalk Databases Forums  

Excessive stored procedure [COMPILE] lock

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Excessive stored procedure [COMPILE] lock in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
imarchenko
 
Posts: n/a

Default Excessive stored procedure [COMPILE] lock - 05-16-2005 , 07:50 PM






Hello!

I am trying to investigate strange problem with particular stored
procedure. It runs OK for several days and suddenly we start getting
and lot
of locks. The reason being [COMPILE] lock placed on this procedure. As
a
result, we have 40-50 other connections waiting, then next connection
using
this procedure has [COMPILE] lock etc. Client is fully qualifying
stored
procedure by database/owner name and it doesn't start with sp_. I know

these are the reasons for [COMPILE] lock being placed. Is there
something
else that might trigger this lock? When troubleshooting this issue, I
noticed there was no plan for this procedure in syscacheobjects. The
stored
procedure is very simple (I know it could be rewritten/optimized but
our
developer wrote it):


CREATE PROCEDURE [dbo].[vsp_mail_select]

@user_id int,
@folder_id int,
@is_read bit = 1, --IF 1, pull everything, else just pull unread mail
@start_index int = null, --unused for now, we return everything
@total_count int = null output, -- count of all mail in specified
folder
@unread_count int = null output -- count of unread mail in specified
folder

AS
SET NOCOUNT ON

select m1.* from mail m1(nolock) where m1.user_id=@user_id and
folder_id=@folder_id and ((@is_read=0 and is_read=0) or (@is_read=1))
order
by date_sent desc
select @total_count = count(mail_id) from mail m1(nolock) where
m1.user_id=@user_id and folder_id=@folder_id and ((is_read=0 and
@is_read=0)
or (@is_read=1))
select @unread_count = count(mail_id) from mail m1(nolock) where
m1.user_id=@user_id and folder_id=@folder_id and is_read=0

GO

I was monitoring server for a couple of day before and I am not sure
why
this happens every 3-4 days only!

Any help on this matter would be greately appreciated!

Thanks,
Igor


Reply With Quote
  #2  
Old   
Razvan Socol
 
Posts: n/a

Default Re: Excessive stored procedure [COMPILE] lock - 05-17-2005 , 01:37 AM






See:
http://support.microsoft.com/default...;en-us;q263889
http://support.microsoft.com/?kbid=836136
Maybe one of them (or the related articles) will help.

Razvan


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.