Thursday, March 22, 2012

Does SHOWCONTIG always use table S-lock?

I noticed that while running a DBCC SHOWCONTIG - this processed blocked
another process attempting to acquire an IX lock on that table. I saw that
the showcontig had an "S" lock on the table.
Is there any way to influence SQL Server into taking an IS lock on the table
and S locks on the pages?
Thanks in advanceWITH FAST Option may help.
also if a table is a heap (No Clustered Index) that will impact this
behavior. You WANT each table to have a clustered index (in General)
Cheers
Greg Jackson
PDX, OR|||Not currently. Even using WITH FAST requires a Shared Table lock (however,
except on the largest tables any blocking should be fairly transient as the
results are returned so quickly)
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"TJTODD" <Thxomasx.Toddy@.Siemensx.com> wrote in message
news:%23%23LyYoZSEHA.3636@.TK2MSFTNGP09.phx.gbl...
> I noticed that while running a DBCC SHOWCONTIG - this processed blocked
> another process attempting to acquire an IX lock on that table. I saw
that
> the showcontig had an "S" lock on the table.
> Is there any way to influence SQL Server into taking an IS lock on the
table
> and S locks on the pages?
> Thanks in advance
>|||Not true. If you only specify WITH FAST for a clustered or non-clustered
index it will acquire an IS table lock - that's the entire reason for me
adding the option in SQL Server 2000.
--
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
news:uJCeJ7aSEHA.3728@.TK2MSFTNGP11.phx.gbl...
> Not currently. Even using WITH FAST requires a Shared Table lock (however,
> except on the largest tables any blocking should be fairly transient as
the
> results are returned so quickly)
> --
> HTH
> Jasper Smith (SQL Server MVP)
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "TJTODD" <Thxomasx.Toddy@.Siemensx.com> wrote in message
> news:%23%23LyYoZSEHA.3636@.TK2MSFTNGP09.phx.gbl...
> > I noticed that while running a DBCC SHOWCONTIG - this processed blocked
> > another process attempting to acquire an IX lock on that table. I saw
> that
> > the showcontig had an "S" lock on the table.
> >
> > Is there any way to influence SQL Server into taking an IS lock on the
> table
> > and S locks on the pages?
> >
> > Thanks in advance
> >
> >
>|||That's what I thought (and I can see now that it is) however when I was
testing before posting my original answer ( I really did test!) I was using
dbcc showcontig('wildtest') with fast
where wildtest has a clustered index and it was getting blocked by an IX
table lock from a transaction I left open so I could examine the locking. I
just tried it again specifying the clustered index explicitly and no
blocking
dbcc showcontig('wildtest',1) with fast
This is what threw me off track :-)
I was under the impression that the first query on a table with a clustered
index would result in the same behaviour as the second one ?
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
news:%231ITfVbSEHA.3812@.TK2MSFTNGP11.phx.gbl...
> Not true. If you only specify WITH FAST for a clustered or non-clustered
> index it will acquire an IS table lock - that's the entire reason for me
> adding the option in SQL Server 2000.
> --
> Paul Randal
> Dev Lead, Microsoft SQL Server Storage Engine
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> "Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
> news:uJCeJ7aSEHA.3728@.TK2MSFTNGP11.phx.gbl...
> > Not currently. Even using WITH FAST requires a Shared Table lock
(however,
> > except on the largest tables any blocking should be fairly transient as
> the
> > results are returned so quickly)
> >
> > --
> > HTH
> >
> > Jasper Smith (SQL Server MVP)
> >
> > I support PASS - the definitive, global
> > community for SQL Server professionals -
> > http://www.sqlpass.org
> >
> > "TJTODD" <Thxomasx.Toddy@.Siemensx.com> wrote in message
> > news:%23%23LyYoZSEHA.3636@.TK2MSFTNGP09.phx.gbl...
> > > I noticed that while running a DBCC SHOWCONTIG - this processed
blocked
> > > another process attempting to acquire an IX lock on that table. I saw
> > that
> > > the showcontig had an "S" lock on the table.
> > >
> > > Is there any way to influence SQL Server into taking an IS lock on the
> > table
> > > and S locks on the pages?
> > >
> > > Thanks in advance
> > >
> > >
> >
> >
>sql

No comments:

Post a Comment