J
John Rivers
Hello,
The common approaches to concurrency control in web apps:
optimistic:
- row version (timestamp, guid, datetime, digest) etc.
- value checking
pessimistic:
- locking fields / locking tables (not discussing here)
I have come up with a slight variation on optimistic value checking
that works a treat:
- first: detect which values have actually been changed by the user
- second: break your record down into "dependency groups" (see below)
- third: if you need to update within dependency group "a"
only check that group for changes (from elsewhere) don't worry about
other fields changing
"dependency group" explanation
record level locking makes the assumption that all the fields
in a record are cross dependent, and an edit in field1 might
conflict with an edit in field2 (of course only a human can know
whether this is the case or not)
however this is rarely the case for the whole record:
"Products" table:
ProductID (not in dependency group as can't be changed)
Description (in dependency group "1")
PriceWithoutTax money (in dependency group "2")
AmountOfTax money (in dependency group "2")
thus if one user updates description (group "1")
and another updates PriceWithoutTax and/or AmountOfTax (group "2")
then this is allowed
this increases the granularity of the concurrency control
leading to less conflicts
and is especially handy for tables with lots of fields
which don't want to be split into two tables
furthermore by detecting and updating only the values
that the user has changed, your transaction log space
will be preserved, instead of getting filled up with
values being replaced by themselves which seems to be
the norm?
all this can be wrapped up in a reusable class library
and applied to many forms with little effort
Best wishes,
John "The Troll" Rivers
The common approaches to concurrency control in web apps:
optimistic:
- row version (timestamp, guid, datetime, digest) etc.
- value checking
pessimistic:
- locking fields / locking tables (not discussing here)
I have come up with a slight variation on optimistic value checking
that works a treat:
- first: detect which values have actually been changed by the user
- second: break your record down into "dependency groups" (see below)
- third: if you need to update within dependency group "a"
only check that group for changes (from elsewhere) don't worry about
other fields changing
"dependency group" explanation
record level locking makes the assumption that all the fields
in a record are cross dependent, and an edit in field1 might
conflict with an edit in field2 (of course only a human can know
whether this is the case or not)
however this is rarely the case for the whole record:
"Products" table:
ProductID (not in dependency group as can't be changed)
Description (in dependency group "1")
PriceWithoutTax money (in dependency group "2")
AmountOfTax money (in dependency group "2")
thus if one user updates description (group "1")
and another updates PriceWithoutTax and/or AmountOfTax (group "2")
then this is allowed
this increases the granularity of the concurrency control
leading to less conflicts
and is especially handy for tables with lots of fields
which don't want to be split into two tables
furthermore by detecting and updating only the values
that the user has changed, your transaction log space
will be preserved, instead of getting filled up with
values being replaced by themselves which seems to be
the norm?
all this can be wrapped up in a reusable class library
and applied to many forms with little effort
Best wishes,
John "The Troll" Rivers