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 439019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:44:05+00:00 2026-05-12T20:44:05+00:00

I have a counter field in a myisam table. To update the counter value

  • 0

I have a counter field in a myisam table. To update the counter value in a multitasking environment (web server, concurrent queries from PHP) I need to lock the record for update.
So I do it like this:

START TRANSACTION; 
SELECT Counter FROM mytable ... FOR UPDATE; 
UPDATE Counter value or INSERT INTO mytable; 
// let's make sleep for 20 seconds here to make transaction longer 
COMMIT; 

As I understand, in MyISAM the whole table should be locked until transaction ends.
And when I initiate concurrent query from PHP, opening script in a browser, it really waits until lock is gone.
But If I select all records from a table with mysql.exe – it selects all records even when lock should still be hold.

So it seems I don’t understand something. Please, explain such a behavior.

  • 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-05-12T20:44:06+00:00Added an answer on May 12, 2026 at 8:44 pm

    MyISAM tables don’t support transactions – START TRANSACTION and COMMIT do nothing.

    You can use LOCK TABLES:

    LOCK TABLES mytable READ;
    ...
    UNLOCK TABLES;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a column family use counter as create table command below: (KEY i
I have a cache counter setup for a Posts class on the comments field.
I have the following smarty code: {foreach from=$additional_fields item=v} {if $v.fieldid eq 5} {php}
I have this simple VB.NET function: Dim endval = Convert.ToInt16(googleXMLdocument...<s:currentItemCount>.Value) - 1 For counter
I have rails app with mongoid model. There's counter field in this model which
I have counter for unique column in my table. Now I have list where
I have a datetime field in my MySql table where the date and time
I have a Javascript function which should update a hidden input field in my
I have a completely blank custom table (DatabaseLogFixLog) with only one field/column called refRecId.
Suppose I have table tags which has a field count that indicates how many

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.