Now I know that bigint is 2^64; that is, more atoms than there are in the known universe. I shouldn't be worried, as my mere human brain simply can't get around the enormity of that number.
现在我知道bigint是2 ^ 64;也就是说,原子比已知宇宙中的原子多。我不应该担心,因为我的人脑只是无法绕过那个数字的巨大。
However, let's say that I record every change to every category, product and order in my system, from launch until the end of time. Should I be concerned about the performance of table writes before I worry about running out of primary key values? Should I record events of different priorities to different event tables? Will I run out of atoms on a hard drive before I run out of bigints? How big should I let an event log table get before I start archiving / clearing it out?
但是,假设我记录了从发布到结束时系统中每个类别,产品和订单的每个更改。在担心主键值耗尽之前,我是否应该关注表写入的性能?我应该将不同优先级的事件记录到不同的事件表中吗?在用完bigint之前,我是否会耗尽硬盘上的原子?在开始存档/清除之前,我应该让事件日志表有多大?
5 个解决方案
#1
13
Even if every of your entries only had 1 byte, 2^64 entries would occupy around 18000000 TB on your hard drive, so I guess you shouldn't worry about this.
即使你的每个条目只有1个字节,2 ^ 64个条目在你的硬盘上占用大约18000000 TB,所以我猜你不应该担心这个。
#2
5
If your application added a record to the table once every millionth of a second, it would run for over five hundred thousand years before it ran out of keys.
如果您的应用程序每百万分之一秒向表中添加一条记录,那么它将在密钥用完之前运行超过五十万年。
#3
2
"How big should I let an event log table get before I start archiving / clearing it out?"
“在开始存档/清除之前,我应该让事件日志表有多大?”
Never clear the event logs -- the information has significant value.
永远不要清除事件日志 - 信息具有重要价值。
However, when some manager insists that an archive is necessary, you can show the cost of storage vs. the cost of your time to (a) think about it, (b) get second and third opinions, and then (c) write a procedure to archive log records.
但是,当某个经理坚持要求存档时,您可以显示存储成本与(a)考虑它的时间成本,(b)获得第二和第三意见,然后(c)写一个归档日志记录的过程。
The cost of storage is plummeting. Your time is better spent on ANYTHING other than purging log records.
存储成本直线下降。除了清除日志记录之外,您的时间最好花在任何事情上。
Bottom line: you have permission to stop wringing your hands. It's all good. You're not making a fundamental mistake.
一句话:你有权停止绞伤你的手。都很好。你没有犯一个根本性的错误。
#4
0
It is highly unlikely that you will ever run out of primary key values. However you may need to give consideration to how you want to access the log table to retrieve data. Use this to inform when you should be archiving or cleaning the data. If the log data is read frequently think about addding indexes to improve read performance but keep in mind that indexes need to be maintained for every record added.
你不太可能用完主键值。但是,您可能需要考虑如何访问日志表以检索数据。用于通知何时应归档或清理数据。如果经常读取日志数据,请考虑添加索引以提高读取性能,但请记住,需要为添加的每个记录维护索引。
#5
0
The way we handle this is by providing a log archiving functionality, that separates out the log table into separate databases by year, allowing us to reset the identity seed on our LogEvent table.
我们处理这个问题的方法是提供日志归档功能,按日将日志表分成不同的数据库,允许我们在LogEvent表上重置身份种子。
We also have different log tables, though only two main ones.
我们也有不同的日志表,但只有两个主要表。
#1
13
Even if every of your entries only had 1 byte, 2^64 entries would occupy around 18000000 TB on your hard drive, so I guess you shouldn't worry about this.
即使你的每个条目只有1个字节,2 ^ 64个条目在你的硬盘上占用大约18000000 TB,所以我猜你不应该担心这个。
#2
5
If your application added a record to the table once every millionth of a second, it would run for over five hundred thousand years before it ran out of keys.
如果您的应用程序每百万分之一秒向表中添加一条记录,那么它将在密钥用完之前运行超过五十万年。
#3
2
"How big should I let an event log table get before I start archiving / clearing it out?"
“在开始存档/清除之前,我应该让事件日志表有多大?”
Never clear the event logs -- the information has significant value.
永远不要清除事件日志 - 信息具有重要价值。
However, when some manager insists that an archive is necessary, you can show the cost of storage vs. the cost of your time to (a) think about it, (b) get second and third opinions, and then (c) write a procedure to archive log records.
但是,当某个经理坚持要求存档时,您可以显示存储成本与(a)考虑它的时间成本,(b)获得第二和第三意见,然后(c)写一个归档日志记录的过程。
The cost of storage is plummeting. Your time is better spent on ANYTHING other than purging log records.
存储成本直线下降。除了清除日志记录之外,您的时间最好花在任何事情上。
Bottom line: you have permission to stop wringing your hands. It's all good. You're not making a fundamental mistake.
一句话:你有权停止绞伤你的手。都很好。你没有犯一个根本性的错误。
#4
0
It is highly unlikely that you will ever run out of primary key values. However you may need to give consideration to how you want to access the log table to retrieve data. Use this to inform when you should be archiving or cleaning the data. If the log data is read frequently think about addding indexes to improve read performance but keep in mind that indexes need to be maintained for every record added.
你不太可能用完主键值。但是,您可能需要考虑如何访问日志表以检索数据。用于通知何时应归档或清理数据。如果经常读取日志数据,请考虑添加索引以提高读取性能,但请记住,需要为添加的每个记录维护索引。
#5
0
The way we handle this is by providing a log archiving functionality, that separates out the log table into separate databases by year, allowing us to reset the identity seed on our LogEvent table.
我们处理这个问题的方法是提供日志归档功能,按日将日志表分成不同的数据库,允许我们在LogEvent表上重置身份种子。
We also have different log tables, though only two main ones.
我们也有不同的日志表,但只有两个主要表。