Friday, March 23, 2012

Gaining complete exclusive access to a given table

Hi Group
While I'm fully aware that there are transations and that stuff like
this should be left to the server administration tools etc. I'm still
facing the problem of writing a middle ware where the existing,
unchangeabel upper layer application want's to get exclusive access
over a complete table and I have to emulate this behaviour in my
module. I figure I could select the complete table in a transaction to
do so, but I have a feeling that this might be pretty slow? Or is such
an apraoch sufficently fast? What better alternatives do I have?
TIA
MarkusWhat exactly are you trying to achieve?
Lock a table inside a transaction? Use locking hints or serializable
isolation level.
We can't give you an accurate answer to a vague question.
ML
http://milambda.blogspot.com/|||On Thu, 27 Apr 2006 15:47:12 +0200, Markus Zingg wrote:

>Hi Group
>While I'm fully aware that there are transations and that stuff like
>this should be left to the server administration tools etc. I'm still
>facing the problem of writing a middle ware where the existing,
>unchangeabel upper layer application want's to get exclusive access
>over a complete table and I have to emulate this behaviour in my
>module. I figure I could select the complete table in a transaction to
>do so, but I have a feeling that this might be pretty slow? Or is such
>an apraoch sufficently fast? What better alternatives do I have?
Hi Markus,
Check out the TABLOCK and HOLDLOCK update hints. They might be what
you're after.
(I assume that you *are* aware that implementing this instantly kills
any chance of ever scaling your app, are yoou?)
Hugo Kornelis, SQL Server MVPsql

No comments:

Post a Comment