The method you have devised will work as you expect it to. It will also perform badly as it will lock out concurrent updates.
You should consider using xdmp:random() to generate a 64 bit random number for your unique identifier. John On 16/12/11 13:55, Raghu wrote: > Hi All, > I need to auto increment an id (long int) based on the incoming > concurrent requests. I'll be incrementing the max of existing value by > 1 and persist the value in the same xml. My assumption is since I'm > doing this in a single transaction and also I have an update statement > in this transaction, a lock will be obtained on that xml so that the > next request will have to wait for the lock to be released and when the > second request increments the id value from the max of existing values > it will take the latest value. Am I right? If not, is there some other > way to do it? Please note that I don't need a timestamp as my ID, I need > to have an integer. I just need the relational database style auto > increment feature which should give me unique id even if there are > concurrent requests.Also note all the requests are from the same user so > I cannot use a lock acquire for that user. > Thanks > Raghu -- John Snelson, Senior Engineer http://twitter.com/jpcs MarkLogic Corporation http://www.marklogic.com _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
