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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:50:30+00:00 2026-06-16T18:50:30+00:00

Does anyone have any recommendations how to implement this? table1 will constantly be INSERT

  • 0

Does anyone have any recommendations how to implement this?

table1 will constantly be INSERTed into. This necessitates that every row on table2 be UPDATEd upon each table1 INSERT. Also, an algorithm that I don’t know if MySQL would be best responsible for (vs PHP calculation speed) also has to be applied to each row of table2.

I wanted to have PHP handle it whenever the user did the INSERT, but I found out that PHP pages are not persistent after servering the connection to the user (or so I understand, please tell me that’s wrong so I can go that route).

So now my problem is that if I use a total table UPDATE in a TRIGGER, I’ll have locks galore (or so I understand from InnoDB’s locking when UPDATing an entire table with a composite primary key since part of that key will be UPDATEd).

Now, I’m thinking of using a cron job, but I’d rather they fire upon a user’s INSERT on table1 instead of on a schedule.

So I was thinking maybe a CURSOR…

What way would be fastest and “ABSOLUTELY” NO LOCKING on table2?

Many thanks in advance!

Table structure

table2 is all INTs for speed. However, it has a 2 column primary key. 1 of those columns is what’s being UPDATEd. That key is for equally important rapid SELECTs.

table1 averages about 2.5x the number of rows of table2.

table2 is actually very small, ~200mb.

  • 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-16T18:50:32+00:00Added an answer on June 16, 2026 at 6:50 pm

    First of all: What you try is close to impossible – I don’t know of an RDBMS, that can escalate INSERTs into one table into UPDATEs of another with “ABSOLUTELY NO LOCKING”.

    That said:

    • my first point of research would be, whether the schema could be overhauled to optimize this hotspot away.
    • if this cannot be achieved, you might want to look into making table2 an in-memory type that can be recreated from existing data (such as keeping snapshots of it together with the max PK of table1 and rolling forward if a DB restart is required). Since you need to update all rows on every INSERT into table1 it cannot be very big.
    • Next point of research would be to put the INSERT and the UPDATE into a stored procedure, that is called by the insertion logic. This would make a runaway situation with the resulting locking hell on catchup much less likely.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have any recommendations for applications or browser plugins that make browsing and
Does anyone have any recommendations for tools that you can add to Eclipse, Netbeans
Does anyone have any recommendations for a JavaScript charting library that allows a user
Does anyone have any recommendations of tools that can be of assistance with moving
Does anyone have any recommendations for a programmer's editor that can cope with large
Does anyone have any recommendations with localization of core data? My application will have
Does anyone have any recommendations of resources for learning ASP.NET specifically? I have a
I am starting to test Haskell for linear algebra. Does anyone have any recommendations
Does anyone have any tips that could help speed up a process of breaking
Does anyone have any recommendations for either of these validation ASP.Net MVC Validation frameworks?

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.