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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:18:24+00:00 2026-05-10T16:18:24+00:00

I’ve got a database which I intend to replicate for backup reasons (performance is

  • 0

I’ve got a database which I intend to replicate for backup reasons (performance is not a problem at the moment).

We’ve set up the replication correctly and tested it and all was fine.

Then we realized that it replicates all the writes to the temporary tables, which in effect meant that replication of one day’s worth of data took almost two hours for the idle slave.

The reason for that is that we recompute some of the data in our db via cronjob every 15 mins to ensure it’s in sync (it takes ~3 minutes in total, so it is unacceptable to do those operations during a web request; instead we just store the modifications without attempting to recompute anything while in the web request, and then do all of the work in bulk). In order to process that data efficiently, we use temporary tables (as there’s lots of interdependencies).

Now, the first problem is that temporary tables do not persist if we restart the slave while it’s in the middle of processing transactions that use that temp table. That can be avoided by not using temporary tables, although this has its own issues.

The more serious problem is that the slave could easily catch up in less than half an hour if it wasn’t for all that recomputation (which it does one after the other, so there’s no benefit of rebuilding the data every 15 mins… and you can literally see it stuck at, say 1115, only to quickly catch up and got stuck at 1130 etc).

One solution we came up with is to move all that recomputation out of the replicated db, so that the slave doesn’t replicate it. But it has disadvantages in that we’d have to prune the tables it eventually updates, making our slave in effect ‘castrated’, ie. we’d have to recompute everything on it before we could actually use it.

Did anyone have a similar problem and/or how would you solve it? Am I missing something obvious?

  • 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. 2026-05-10T16:18:25+00:00Added an answer on May 10, 2026 at 4:18 pm

    I’ve come up with the solution. It makes use of replicate-do-db mentioned by Nick. Writing it down here in case somebody had a similar problem.

    The problem with just using replicate-(wild-)do* options in this case (like I said, we use temp tables to repopulate a central table) is that either you ignore temp tables and repopulate the central one with no data (which causes further problems as all the queries relying on the central table being up-to-date will produce different results) or you ignore the central table, which has a similar problem. Not to mention, you have to restart mysql after adding any of those options to my.cnf. We wanted something that would cover all those cases (and future ones) without the need for any further restart.

    So, what we decided to do is to split the database into the ‘real’ and a ‘workarea’ databases. Only the ‘real’ database is replicated (I guess you could decide on a convention of table names to be used for replicate-wild-do-table syntax).

    All the temporary table work is happening in ‘workarea’ db, and to avoid the dependency problem mentioned above, we won’t populate the central table (which sits in ‘real’ db) by INSERT … SELECT or RENAME TABLE, but rather query the tmp tables to generate a sort of a diff on the live table (ie. generate INSERT statements for new rows, DELETE for the old ones and update where necessary).

    This way the only queries that are replicated are exactly the updates that are required, nothing else, ie. some (most?) of the recomputation queries hapenning every fifteen minutes might not even make its way to slave, and the ones that do will be minimal and not computationally expensive at all, just simple INSERTs and DELETEs.

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

Sidebar

Ask A Question

Stats

  • Questions 205k
  • Answers 205k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer fun(Condition) ->Condition(Message) end is a lambda function that applies the… May 12, 2026 at 9:03 pm
  • Editorial Team
    Editorial Team added an answer Your library could check the Target of each delegate in… May 12, 2026 at 9:03 pm
  • Editorial Team
    Editorial Team added an answer I've built an engine that does something very similar to… May 12, 2026 at 9:03 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS
I am currently running into a problem where an element is coming back from

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.