压缩日期的最佳方法是什么?
我的网站需要在mysql上存储每次访问的ip和时间戳。我担心很快我的数据库中就会有 1e6 行。
在 mysql 或 java 上压缩日期的最佳方法是什么? mysql 已经压缩日期了吗?理想情况下,我想快速解压缩日期值以生成报告。
更新:抱歉,我的意思是每天一百万。但我想这仍然是微不足道的。
my site needs to store the ip and timestamp of every visit on mysql. i am concerned that very quickly i will have 1e6 rows in my database.
what is the best way to compress a date on mysql or java? does mysql already compress dates? ideally, I would like to un-compress the date values rather quickly to generate reports.
Update: sorry i meant a mil per day. but I guess that is still minuscule.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
伙计,一百万行是一个微小数据库。我不会对此太担心。无论如何,MySQL 按照 此页面:
换句话说,在位级别(基于
1000-01-01 至 9999-12-31
范围):Mate, one million rows is a tiny database. I wouldn't be worrying too much about that. In any case, MySQL uses a pretty compressed format (3 bytes) anyway as per this page:
In other words, at bit level (based on the
1000-01-01 thru 9999-12-31
range):使用内置的 MySQL 日期时间类型。一百万行并不算多。
Use the built in MySQL datetime type. A million rows isn't that many.
mysql 时间戳只有 4 个字节。表示时间戳的整数将是相同的。将其保存为 mysql 类型会很有效,因为您可以有效地基于该列进行索引和/或查询。
任何非 mysql 类型的“压缩”形式查询效率都会很低。
A mysql timestamp would be only 4 bytes. An integer representing the timestamp would be the same. It would be efficient to save it as a mysql type since you'd be able to index and/or query based on that column efficiently.
Any "compressed" form not a mysql type would be inefficient to query.