Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

What is extended proc sp_releaseschemalock Expand / Collapse
Author
Message
Posted Tuesday, September 5, 2006 8:15 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, August 9, 2009 4:41 AM
Points: 41, Visits: 112

Does anyone have documentation or know what sp_releaseschemalock does?

I had an issue that occurred last week when I was on vaca. The above proc was blocking for over 24 hours being called thru linked server.  All my logs are gone so I do not know who or what. All I have is he was the head of the chain..

The application experienced issues during this window and my boss wanted me to se if I saw anything.

The blocking continued until sql was restarted. 

It is sql2000 sp4.

 

Post #306282
Posted Tuesday, September 5, 2006 10:33 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, October 8, 2014 10:43 AM
Points: 197, Visits: 194

I've seen this happen where there was a linked server query running and killed.  However the connection persisted and was reporting it was at a 100 percent in the rollback state, but was blocking other queries.  I simply stopped / started DTC on the linked server and then the connection cleared.  In my several cases, this has always worked for me without having to stop/start sqlserver.

 

You should check your linked server configurations and make sure they are "collation compatible" checked. Otherwise the entire remote table is returned to the local calling server to execute the WHERE clause.

In regards to sp_releaseschemalock ....below is part of a rootcause analysis I had to give one time before.  I've edited it quite a bit to rip out tablenames/queries we use.  I used profiler to capture these sprocs.

 

This is one of many sp's which are called as a result of a linkedserver query.

 

sp_tables_info_rowset tblXXX

sp_columns_rowset tblXXX

sp_indexes_rowset tblXXX

sp_check_constbytable_rowset tblXXX

sp_provider_types_rowset tblXXX

sp_table_statistics_rowset tblXXX

sp_getschemalock tblXXX

exec sp_prepexec @P1 output, NULL, N'SELECT "Col1601" FROM (SELECT "some dynamic generated query" FROM "dbname"."dbo"."tblName" WHERE somecriteria)

sp_releaseschemalock tblXXX

sp_releaseschemalock tblXXX

sp_releaseschemalock tblXXX

 

All of this overhead generates a lot of disk IO's and stacks up on the blocking.

All of this occurs because the SQL Server on serverA has no statistical information about the tables involved in the linked query.  ServerB will always inquire that information for each call.

 

 

Hope this helps out some.




Post #306330
Posted Wednesday, August 13, 2008 12:20 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, October 14, 2014 12:56 PM
Points: 193, Visits: 378
Yea, there is not much out there on sp_getschemalock or sp_releaseschemalock.
I did find some reference to the locks on the schema (BOL) locks sch-m, sch-s if you do a search.



The more you are prepared, the less you need it.
Post #552168
Posted Thursday, October 8, 2009 8:06 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, October 17, 2014 4:11 AM
Points: 310, Visits: 409
Hi all,

I have a stored-procedure running on an SQL2k5 box which is updating a table on a SQL2k linked server.

I have ensured that the "Collation Comaptible" optiions are set True at both ends of the link, but still my query seems to perform a full table scan (some 2million+ rows) for a single update.

The where clause is matching a single value of the primary key ( an integer identity column) and updating a single row in the table.

collation of the remote DB (on the sql2k box) is SQL_Latin1_General_CP1_CI_AS
collation of the local DB (where the Sp runs from ) is SQL_Latin1_General_CP1_CI_AS

can anyone suggest how to prevent the full table scan? this is taking anything from 45 minutes to 1.5 hours to run,

many thanks in advance



Post #800030
Posted Friday, October 9, 2009 2:34 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, October 17, 2014 4:11 AM
Points: 310, Visits: 409
Well, i didn't work out how to stop the full table scan when performing updates across linked-servers, but there is a better way of achieving the required result (as always!).

rather than have an update statement on the remote server, i have added a stored procedure to the linked server which i simply pass the required primary key value to; the Sp on linked server then performs the update.

so use;
exec linkedserver.db.dbo.sp @pk_id

rather than;
update linkedserver.db.dbo.table set a = b were pk_id = @pk_id

Result is no schema lock required and the process is now running in a few seconds rather than 45 minutes.

hope this helps other folk with the same performance hit when using linked servers.

....I would still ike to know if it's possible to prevent the full table scan on linked server table updates, so if anyone can contribute to the thread along these lines please do so!

cheers



Post #800576
Posted Wednesday, September 29, 2010 8:41 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, October 14, 2012 1:02 AM
Points: 3, Visits: 49
I had the same issue. It had to do with a schema changed being applied via linked server. I killed the spid and the blocking was gone..
Post #995707
Posted Monday, November 12, 2012 5:11 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, August 6, 2013 12:44 AM
Points: 3, Visits: 61
I am having similar issue on SQL 2008 where there is a view created on Server A which retrieves data from 3 tables ( 1,2,3) residing on Server B through linked server . There is blocking that happens when there is process that tries to UPDATE table 3 .
It waits on lock for one of the table 'Table 1' which takes part in the view defintion.
This is been blocked by a SPID which is executing [sys.sp_releaseschemalock] called by from 'Microsoft SQL Server '

I already tried the option 'collation compatible' true but it dint help.
Any help would be appreciated
Post #1383619
Posted Monday, November 12, 2012 5:21 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, October 17, 2014 4:11 AM
Points: 310, Visits: 409
Are you able to set-up replication of the 3 tables from server B to server A; the view on A will then be much more efficient and replication is very simple to set-up?

cheers



Post #1383628
Posted Wednesday, November 14, 2012 1:14 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, August 6, 2013 12:44 AM
Points: 3, Visits: 61
We dont want to setup replication.. we would like to use the current setup.
When both database are on same SQL instance ( that is when the view is created without calling linked server ) we dont face this issue
Post #1384434
Posted Saturday, September 6, 2014 10:21 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 12:09 AM
Points: 35,348, Visits: 31,886
Shawn Wilson (9/5/2006)


I've seen this happen where there was a linked server query running and killed. However the connection persisted and was reporting it was at a 100 percent in the rollback state, but was blocking other queries. I simply stopped / started DTC on the linked server and then the connection cleared. In my several cases, this has always worked for me without having to stop/start sqlserver.<FONT size=2>

You should check your linked server configurations and make sure they are "collation compatible" checked. Otherwise the entire remote table is returned to the local calling server to execute the WHERE clause.</FONT>

In regards to sp_releaseschemalock ....below is part of a rootcause analysis I had to give one time before. I've edited it quite a bit to rip out tablenames/queries we use. I used profiler to capture these sprocs.

This is one of many sp's which are called as a result of a linkedserver query.

<FONT face="times new roman" size=3>sp_tables_info_rowset tblXXX</FONT>

<FONT face="times new roman" size=3>sp_columns_rowset tblXXX</FONT>

<FONT face="times new roman" size=3>sp_indexes_rowset tblXXX</FONT>

<FONT face="times new roman" size=3>sp_check_constbytable_rowset tblXXX</FONT>

<FONT face="times new roman" size=3>sp_provider_types_rowset tblXXX</FONT>

<FONT face="times new roman" size=3>sp_table_statistics_rowset tblXXX</FONT>

<FONT face="times new roman" size=3>sp_getschemalock tblXXX</FONT><FONT face="times new roman" size=3></FONT>

<FONT face="times new roman" size=3>exec sp_prepexec @P1 output, NULL, N'SELECT "Col1601" FROM (SELECT "some dynamic generated query" </FONT><FONT face="times new roman" size=3>FROM "dbname"."dbo"."tblName"WHERE somecriteria)</FONT>

<FONT face="times new roman" size=3>sp_releaseschemalock tblXXX</FONT>

<FONT face="times new roman" size=3>sp_releaseschemalock tblXXX</FONT>

<FONT face="times new roman" size=3>sp_releaseschemalock tblXXX</FONT>

<FONT face="times new roman" size=3></FONT>

<FONT face="times new roman" size=3>All of this overhead generates a lot of disk IO's and stacks up on the blocking.</FONT>

<FONT face="times new roman" size=3>All of this occurs because the SQL Server onserverA has no statistical information about thetablesinvolved in the linked query. ServerBwill always inquire that information for each call.</FONT>

<FONT face="times new roman" size=3></FONT>

<FONT face="Times New Roman" size=3></FONT>

<FONT face="Times New Roman" size=3>Hope this helps out some.</FONT>


I know this is an 8 year old post but I wanted to say thanks... this is good stuff and just exactly what I was looking for.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1611189
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse