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 12345»»»

Use of Identity Property to Resolve Concurrency Issues Expand / Collapse
Author
Message
Posted Wednesday, February 23, 2011 9:55 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, September 2, 2014 6:56 PM
Points: 33, Visits: 280
Comments posted to this topic are about the item Use of Identity Property to Resolve Concurrency Issues

Ajit Ananthram
Blog - http://ajitananthram.wordpress.com
Post #1068652
Posted Wednesday, February 23, 2011 11:43 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 14, 2011 6:16 AM
Points: 4, Visits: 30
Removed the rude coment. I am sorry.

Microsoft MVP 2006-2010
Post #1068680
Posted Thursday, February 24, 2011 2:00 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 4:14 AM
Points: 1,152, Visits: 1,107
And your reply teaches us that you are ill-mannered and rude.

Good article, Ajit. Very well written, clear and concise.
Post #1068717
Posted Thursday, February 24, 2011 2:03 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 14, 2011 6:16 AM
Points: 4, Visits: 30
You are right, I appologize.

I am really sorry - I let my own problems take over.


Microsoft MVP 2006-2010
Post #1068720
Posted Thursday, February 24, 2011 2:14 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 7:29 AM
Points: 895, Visits: 2,443
I'm not sure that setting the seed to the next number in logical order is the right way, Personally I would be setting the seed to start from a number somewhat larger than the current, simply to avoid the chance of collisions.

In your example rather than setting the seed to Current+1 I would be inclined to set it to 100 (or some other factor of 10 depending on the current position), this way I could easily Identify the rows that were assigned by the new method and track any issues that were being created.

As you state in the article,the introduction of Denali solves this type of problem with the new SEQUENCE statement.


_________________________________________________________________________
SSC Guide to Posting and Best Practices
Post #1068728
Posted Thursday, February 24, 2011 2:18 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, June 11, 2014 5:49 AM
Points: 8, Visits: 99
nice, good article never thought about how your could use vertical tables to solve that, and will also go and look at sequences in the next sql release!.

Can I ask why in the original code the lock on the kvp was required for the duration of the whole buniness transaction. Could they just not of got the required key values into some temps using some short transactions before the main long running business process transaction took place?


come to think about it, the kvp would not even need to be in a transaction if all they want is to increment a seed, a single update key statement to increment and at the same time assign the read value to a temp.

thanks
Post #1068733
Posted Thursday, February 24, 2011 3:04 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, May 29, 2013 9:33 PM
Points: 21, Visits: 49
Just my thought on this article...

Why do we need a begin transaction statement at the start of the procedure USP_Business_Process. Everytime the sub-procedure : USP_Get_Value_For_Key is called, it will always have a unique value.

So, the statement : BEGIN TRANSACTION Business_Process, should be after the call to the procedure USP_Get_Value_For_Key.

i.e after the statement : SELECT @val -- Print key value for display,
in the procedure: USP_Business_Process.

This way there will be no blocking issue for the table: tbl_kvp

Haven't tested this but think this should work.
Post #1068757
Posted Thursday, February 24, 2011 3:05 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, July 19, 2014 3:43 PM
Points: 8, Visits: 36
Does your solution really solve the issue?

What if the requirement was for no gaps in the key sequence? Doesn't using identities in this way lead to gaps in the key sequence if a transaction is rolled back.

There is often a requirement to keep a continuous sequence, such as when assigning invoice numbers, in which case the original USP was correct, but your replacement may lead to gaps in sequence.
Post #1068758
Posted Thursday, February 24, 2011 3:07 AM
SSC-Enthusiastic

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

Group: General Forum Members
Last Login: Thursday, July 17, 2014 12:56 AM
Points: 168, Visits: 77
May i know how it will help while updating the records. (ie. multiple users updating same record from the different sessions). As per your message, it will allow multiple users to update the same record.
Post #1068759
Posted Thursday, February 24, 2011 3:32 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, October 14, 2014 4:52 AM
Points: 223, Visits: 278
Why use the output syntax, table variable and dynamic sql?

Wouldn't the following be simpler (no permissions issue on table if user running it only has access to SP either) :

insert into ...
set @outputId = scope_identity()
Post #1068770
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse