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

Query over slow connection, when are locks released? Expand / Collapse
Author
Message
Posted Tuesday, January 21, 2014 6:45 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 3:21 AM
Points: 92, Visits: 373
Hi

I have a quite complex Reporting View using other views.
The output of this view is being sent over a v.slow network connection.

It is causing other apps on that DB that write to the DB to slow down. It's is Locking rather than I/O issue.


My question:
Are the locks held for the time it takes to run the query only or also the time taken to return results to the client?
i.e. is the client's connection speed relevant?

If I were to change it to a SP, is it worth selecting everything First into a temp table and then returning the select from temp table. So only the temp table is locked while the results are sent.

I think the cursor/recordset at the client end is readonly, not the dynamic sort (notify of changes)

i.e.

create proc mySP
AS
Select fieldlist INTO #t from (reproduce view's joins and logic)

SELECT * FROM #t


I think it should not make a difference, but wanted to check to clear up my understanding.
P.S. I do NOT intend to use NOLOCK
Post #1533026
Posted Tuesday, January 21, 2014 7:04 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Yesterday @ 3:46 PM
Points: 42,462, Visits: 35,525
Have you considered one of the row-versioning based isolation levels?


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1533035
Posted Tuesday, January 21, 2014 7:26 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 3:21 AM
Points: 92, Visits: 373
Thanks for relying Gila

I don't know of this concept.

However it's a 3rd party DB I cannot make changes to it.

As a simplified model I THOUGHT Sql executed the locking as it sees fit or instructed to do and places the results into temp store (memory/tempdb?). It then releases locks and starts sending the data.
Post #1533057
Posted Tuesday, January 21, 2014 7:44 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Yesterday @ 3:46 PM
Points: 42,462, Visits: 35,525
Close enough. Shared locks are released no later than the end of the query (assuming default isolation level), exclusive locks are held til the end of the transaction


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1533077
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse