Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8394835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:09:19+00:00 2026-06-09T20:09:19+00:00

When updating the field like this it will lock the field: UPDATE table SET

  • 0

When updating the field like this it will lock the field:

UPDATE table SET field = field + 1

Since this is a part of a counter that is expecting a bit of a load, I am afraid not all the count will be registred when multiple users comes to my site.

Is there a better way or a fix of doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:09:21+00:00Added an answer on June 9, 2026 at 8:09 pm

    Your solution:

     UPDATE table SET field = field + 1
    

    is absolutely perfect. That is a single SQL statement, which is fully executed without side effect or not at all. All you could additionally do is, to check weather your statement was actually executed. If not, you could retry to execute it. But there is no real reason for that. You can leave it as it is… In most cases when correctly written statements fail, there is another reason (like an overloaded DB) and retrying would make things even worse.

    If you only have short write/read accesses to that table everything is fine; if concurrent commands need to access it, they will wait until the lock is freed and they will execute then.

    Only if you have very time consuming operations on THAT same table that take more than 1-2 seconds to execute. Then you might loose some countings. The timeout to wait for aquiring the lock is usually something as 10 oder 30 seconds. You could also loose counts, if a process does just manually lock the table (e.g. “LOCK table”) and does not free it. This would be a bug … Other SQL statements wouldnt be able to aquire a lock and finally would be aborted after some longer waiting period.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found something that works with updating one field at here: http://www.karlrixon.co.uk/articles/sql/update-multiple-rows-with-different-values-and-a-single-sql-query/ UPDATE person
I begin by adding data to table events , field exceptions like this function
In the below C++ code, i am updating a field of emp table based
I have a table in my database which is house, that has many field
I'm currently inserting/updating fields like this (if there's a better way, please say so
Background I have a large number of fields that will be updating real time
I want to set a cron job that will execute every 15 minutes. Before
I want to do something like this.. I have a update form in PHP,
should always the version field be checked when updating a domain class object ?
I'm having problems updating records to contain NULL values - in particular, a field

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.