MySQL Forums
Forum List  »  Backup

Re: Backup and trimming data idea
Posted by: Rick James
Date: July 06, 2012 09:57AM

PARTITIONing...

0. Read the online docs on PARTITIONing. Read the PARTITION forum. Google it on Yahoo. Etc.

1. Decide whether it is worth doing at all. Design how to partition. See the PARTITION section of Rick's RoTs (link given above). As for "daily" vs "weekly" vs "monthly" -- I recommend no more than, say, 50 partitions in a table. Daily partitions for 2 months is ok, but stretching it. Two year's worth of data could be done in monthly, not weekly, and certainly not daily, partitions. (731 partitions is permitted, but there will be issues with such.)

2. ALTER TABLE ADD PARTITIONS... This can be done before adding data, at which point it can be part of the CREATE TABLE statement. Or at any time afterwards, but more data = longer time to do the ALTER.

3. Write a script(s) to do the periodic DROP PARTITION (to delete old data) and REORGANIZE PARTITION (to split the 'future' partition into next day/month + 'future').

Do not embark on this until you are comfortable with the steps, or the need for DELETE performance forces you into it.

Test everything on a separate copy (possibly out-of-date) of the live data. DROP PARTITION is a clear win over DELETE, but other reasons for PARTITIONing may turn out to be useless, or even hurt performance.

The PRIMARY KEY and other INDEXes may need to change when you go to PARTITIONing. This is part of the design / experimentation you need to do.

Until 5.6(?) there is no convenient way to move a single partition to another table. This might be handy for the "backup and trimming data" implied in this thread's title.

Options: ReplyQuote


Subject
Views
Written By
Posted
3508
June 22, 2012 07:34PM
1687
June 23, 2012 05:23PM
1745
June 23, 2012 05:36PM
1763
June 24, 2012 01:51PM
1796
June 25, 2012 10:16AM
1650
June 26, 2012 08:14AM
1746
June 26, 2012 08:46AM
1630
June 27, 2012 08:36AM
1730
June 27, 2012 09:03AM
1593
June 28, 2012 11:19PM
1546
June 29, 2012 07:12AM
1549
June 30, 2012 11:50AM
1625
July 02, 2012 09:47AM
1567
July 03, 2012 01:32PM
1614
July 05, 2012 11:13AM
Re: Backup and trimming data idea
1783
July 06, 2012 09:57AM
1572
July 07, 2012 10:50AM
1595
July 08, 2012 09:33AM
1585
July 16, 2012 08:08PM
1564
July 21, 2012 10:57PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.