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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:43:27+00:00 2026-06-15T11:43:27+00:00

I am planning on writing the following query: INSERT INTO summary (user_id, total_points, count_operations)

  • 0

I am planning on writing the following query:

INSERT INTO summary (user_id, total_points, count_operations)
SELECT 
   15 AS user_id,
   (SELECT SUM(points) FROM operations WHERE user_id = 15) AS total_points,
   (SELECT COUNT(*) FROM operations WHERE user_id = 15) AS count_operations
ON DUPLICATE KEY UPDATE
total_points = VALUES(total_points), 
count_operations = VALUES(count_operations);

Is the whole statement atomic? i.e. does MySQL (with MyISAM engine) internally locks the operations table?

Is there a possibility that MySQL would execute the two subsqueries sequentially which could result in some cases (if a new operation is added within that timeframe) that the total_points and count_operations would be inconsistent?

  • 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-15T11:43:29+00:00Added an answer on June 15, 2026 at 11:43 am

    MyISAM still uses table-level locks.

    These storage engines avoid deadlocks by always requesting all needed
    locks at once at the beginning of a query and always locking the
    tables in the same order. The tradeoff is that this strategy reduces
    concurrency; other sessions that want to modify the table must wait
    until the current DML statement finishes.

    So other processes that want to update the tables you’re using have to wait until your transaction is finished. If it puts a read lock on the table “operations”, all subsequent write locks go into a queue and wait.

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

Sidebar

Related Questions

I'm planning on writing a program for Linux that uses text to speech and
I'm planning on writing a simple SSH client in C/C++ for a project in
I have a multi-project ASP.NET + C# solution. I was planning on writing a
I am planning on re-writing a Win32 application (native C++) in .NET - most
I planning to split my systems into front-end and back-end. Currently my application directly
I am planning on writing a hierarchical organizational control, similar to an org chart.
I'm planning on writing an app and building against 2.2 Froyo (API Level 8).
I'm planning on writing a game, which will use a lot of sprites and
I'm planning on writing a spine/backbone.js style web application which basically just transfers a
I'm planning on writing a medium-size WinForms application that I'll write in C#, .NET

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.