<p>We have a live MySQL database that is 99% INSERTs, around 100 per second. We want to archive the data each day so that we can run queries on it without affecting the main, live database. In addition, once the archive is completed, we want to clear the live database.</p>

<p>What is the best way to do this without (if possible) locking INSERTs? We use INSERT DELAYED for the queries.</p>

[{'answer_id': 65156, 'author': 'Doug T.', 'author_id': 8123, 'author_profile': 'https://Stackoverflow.com/users/8123', 'pm_score': 0, 'selected': False, 'text': '<p>Could you keep two mirrored databases around? Write to one, keep the second as an archive. Switch every, say, 24 hours (or however long you deem appropriate). Into the database that was the archive, insert all of todays activity. Then the two databases should match. Use this as the new live db. Take the archived database and do whatever you want to it. You can backup/extract/read all you want now that its not being actively written to.</p>\n\n<p>Its kind of like having mirrored raid where you can take one drive offline for backup, resync it, then take the other drive out for backup. </p>\n'}, {'answer_id': 65356, 'author': 'Alister Bulman', 'author_id': 6216, 'author_profile': 'https://Stackoverflow.com/users/6216', 'pm_score': 5, 'selected': True, 'text': '<p><a href="http://www.maatkit.org/" rel="noreferrer">http://www.maatkit.org/</a> has mk-archiver</p>\n\n<blockquote>\n  <p>archives or purges rows from a table to another table and/or a file. It is designed to efficiently “nibble” data in very small chunks without interfering with critical online transaction processing (OLTP) queries. It accomplishes this with a non-backtracking query plan that keeps its place in the table from query to query, so each subsequent query does very little work to find more archivable rows.</p>\n</blockquote>\n\n<p>Another alternative is to simply create a new database table each day.  MyIsam does have some advantages for this, since INSERTs to the end of the table don\'t generally block anyway, and there is a merge table type to being them all back together.  A number of websites log the httpd traffic to tables like that.</p>\n\n<p>With Mysql 5.1, there are also partition tables that can do much the same.</p>\n'}, {'answer_id': 68155, 'author': 'Seun Osewa', 'author_id': 6475, 'author_profile': 'https://Stackoverflow.com/users/6475', 'pm_score': 1, 'selected': False, 'text': '<p>MySQL replication would work perfectly for this.<br>\nMaster -> the live server.<br>\nSlave -> a different server on the same network.</p>\n'}, {'answer_id': 74168, 'author': 'Jacob', 'author_id': 8119, 'author_profile': 'https://Stackoverflow.com/users/8119', 'pm_score': 2, 'selected': False, 'text': '<p>Sounds like replication is the best solution for this.  After the initial sync the slave gets updates via the <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-log.html" rel="nofollow noreferrer">Binary Log</a>, thus not affecting the master DB at all.</p>\n\n<p><a href="http://dev.mysql.com/doc/refman/5.0/en/replication.html" rel="nofollow noreferrer">More on replication.</a></p>\n'}, {'answer_id': 883876, 'author': 'Eduardo Xavier', 'author_id': 107452, 'author_profile': 'https://Stackoverflow.com/users/107452', 'pm_score': 2, 'selected': False, 'text': "<p>I use mysql partition tables and I've achieve wonderful results in all aspects.</p>\n"}, {'answer_id': 1101280, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>MK-ARCHIVER is a elegant tool to archive MYSQL data.</p>\n\n<p><a href="http://www.maatkit.org/doc/mk-archiver.html" rel="nofollow noreferrer">http://www.maatkit.org/doc/mk-archiver.html</a></p>\n'}]
['https://Stackoverflow.com/questions/65093', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2183/']