在 MySQL 中删除软删除行有什么好处吗?
我在 MySQL dB 中有一个表,用于记录用户何时单击某些导航选项卡。每次它都会软删除最后一个条目并插入一个新条目。软删除的原因是出于分析目的,因此我可以随着时间的推移跟踪用户点击的位置/时间/内容。软删除与新条目的比例为9:1,表大小目前约为20K,但增长很快。
所以我的问题是:删除软删除条目是否有助于优化涉及该表的任何查询?目前有一个将 4 个表连接在一起并且只需要新条目。由于可以在备份副本上执行软删除的分析,因此我不需要生产 DB 上的这些行。
I have a table in MySQL dB that records when a person clicks on certain navigation tabs. Each time it will soft-delete the last entry and insert a new one. The reason for soft-delete is for analytics purposes, so I can track over time where/when/what users are clicking. The ratio of soft-deletes to new entries are 9:1, and the table size is about 20K at the moment but growing fast.
So my question is: if deleting the soft-delete entries would help optimize any queries that involve this table? There is one at the moment that joins 4 tables together and only needs the new entries. Since the analytics on the soft-deletes could be performed on backup copies, I don't need these rows on the production dB.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 90% 的表排除在所有查询之外很可能会对性能产生影响,但分析:您的索引可能比这些软删除行位于其自己的表中时更大,磁盘头必须寻找跨越更大的距离,因此您的磁盘访问比表 1/10 大小等中的成本更高。
There is most likely a performance implication to have 90% of your table excluded out of all queries but the analytics: your indexes are probably bigger than they would be if these soft-deleted rows were in their own table, the disk head has to seek across bigger distances so your disk accesses are more expensive than they would be in table 1/10 the size etc.