I want to ask a question about approaches in highload web applications development using SQL databases. Assume we have simple CMS system providing access to different articles. Also we want to store article visits quantity in database. This visits counter increases every time when user watches the article.
In terms of SQL database, we have "visits" integer field in the table "Article" that we need to increase every time when user visits the article. If article has a large number of concurrent visits, it is necessary to correctly modify "visits" field value of current database row.
I use pessimistic locking approach: "SELECT .. FOR UPDATE". Every time, when user visits some article, I make a lock on specific row on "Article" table and increase "visits" counter.
Is this approach correct?
I'm using MySQL database in my projects.