2

I have a table Users (simplified) :

UserId (int, PK) | Username | PasswordHash | LastVisitTimestamp

Every time user visits a web site, LastVisitTimestamp column is updated.

Is it a good idea to move that column into a separate table, so that timestamp updates do not lock entire row (actual row is bigger than presented here).

I did that because I was frequently getting "row modified" exception when updating user information (result of update with optimistic concurrency).

Or is there a better (preferred) way to handle this?

THX-1138
  • 21,316
  • 26
  • 96
  • 160
  • "row modified" -- souhds like you have multiple SQL statements that need to be combined in a "transaction". – Rick James May 21 '23 at 06:11

1 Answers1

1

Yes, this is totally legit way of solving the problem.

Another ideas are storing such data in memory-based storage, accumulate and dump to database once per few seconds in batches...

BarsMonster
  • 6,483
  • 2
  • 34
  • 47