Search code examples
mysqlmultithreadingmariadbdatabase-performance

How to do non-obtrusive number-crunching on mysql db?


Not sure how to state this question.

I have a very busy DB in production with close to 1 million hits daily.

Now I would like to do some research on the real-time data (edit: "real-time" can be a few minutes old).

What is the best way to do this without interrupting production?

Ideas:

  1. in the unix shell, there is the nice concept. It lets me give a low priority to a specific thread so it only uses CPU when the other threads are idle. I am basically looking for the same in a mysql context.
  2. Get a DB dump and do the research offline:
    • Doesn't that take down my site for the several minutes it takes to get the dump?
    • Is there a way to configure the dump command so it does the extraction in a nice way (see above)?
  3. Do the SQL commands directly on the live DB:
    • Is there a way, again, to configure the commands so they are executed in a nice way?

Update: What are the arguments against Idea 2?


Solution

  • From the comments on StackOverflow and in-person discussions, here's an answer for whoever gets here with the same question:

    • In MySQL, there seems not to be any nice type control over prioritization of processes (I hear there is in Oracle, for example)
    • Since any "number-crunching" is at most treated like one more visitor to my website, it won't take down the site performance-wise. So it can safely be run in production (read-only, of course...).