使用 App Engine 自动生成的 ID 时可能会出现热门平板电脑问题吗?
热片问题描述如下: http://ikaisays. com/2011/01/25/app-engine-datastore-tip-monotonically-increasing-values-are-bad/
我想我之前读过自动生成的 ID 可能会受到此问题的影响,我认为这是还是这样吗?
如果是这样,像在前面插入随机字母或反转数字顺序这样的简单技巧会有所帮助吗? (我正在寻找一种方法来解决这个问题,同时保持密钥尽可能短......)
The hot tablets problem is described here:
http://ikaisays.com/2011/01/25/app-engine-datastore-tip-monotonically-increasing-values-are-bad/
I think I've read before that auto-generated IDs can suffer from this, I assume it's still the case?
If so, would a simple trick like inserting a random letter in front or reversing the order of the digits would help with this ? (I'm searching for a way to work around this problem while keeping keys as short as possible...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将模型部署到 App Engine 时,将模型放入数据存储区时生成的 ID 号不会单调增加(它们在 dev_appserver 中会单调增加)。您可能会看到较短的范围,但数字会出现相当大的波动。我不确定他们这样做是否是专门为了击败单调递增的索引,但这是一个副作用。
如果您不相信这一点,我经常做的是使用 uuid.uuid4() 创建一个密钥名称(假设您使用的是 Python)。
The ID numbers generated when you put a model in the datastore don't increase monotonically when deployed to App Engine (they do in dev_appserver). You may see short ranges, but the numbers bounce around quite a bit. I'm not sure if they do this specifically to defeat monotonically increasing indexes, but that's a side effect.
If you don't trust that, what I often do is create a key name using uuid.uuid4() (assuming you are using Python).