MySQL Prune old rows to one per day -
i have huge mysql table, , grows around 90 rows per second, every 4 hours 1.3 million rows gets dumped in there timestamp
user(varchar) | created_at(timestamp) ---------------------------- user 1 | 2016-01-27 08:00:00 user 2 | 2016-01-27 08:00:00 user 3 | 2016-01-27 08:00:00 ... user 1 | 2016-01-27 12:00:00 user 2 | 2016-01-27 12:00:00
etc... best approach pruning data older month have 1 row per day?
there rows @ 00:00 thinking along lines of
created_at >= date + 00:00 , created_at < date + 19:59
or
select user, max(created_at) table created_at = date group username
for such large amount of data, may want use partitions manage data, running delete statements filter on large tables can take long time. when create partitions month, removing partition super fast. delete data in month, may need store user summary in table before removing partition.
Comments
Post a Comment