简体   繁体   中英

MySQL - archive table data

I would like to learn how I can archive old table data in a separate table automatically.

I have a very big table which grows and grows constantly. The actually relevant data for me is the latest ~1000 rows. All other data is "nice to have" but is irrelevant. So I want to move it to separate location in order to speed up SELECT queries.

Sounds like you need to set up a scheduled job of some sort. There are multiple ways to go about this, but this simplest way (in my opinion) is to set up a Cron Job , since you're on Linux. You can use it to go off every day, or however often you want, and have it kick of a sql script to move the data for you, past your threshold.

You can also supposedly schedule jobs in MySQL, but I've never done this.

This answer is just to answer the conceptual question, but not to provide technical details, since I'm not sure that's what you need. I'm happy to edit my answer to provide a cron example if you need it.

Hopefully that helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM