SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Query over slow connection, when are locks released?


Query over slow connection, when are locks released?

Author
Message
terry999
terry999
Old Hand
Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)

Group: General Forum Members
Points: 329 Visits: 677
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
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86957 Visits: 45267
Have you considered one of the row-versioning based isolation levels?

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


terry999
terry999
Old Hand
Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)

Group: General Forum Members
Points: 329 Visits: 677
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.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86957 Visits: 45267
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, MVP, M.Sc (Comp Sci)
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


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search