简体   繁体   English

ClearDB 自动递增

[英]ClearDB auto-increment

I'm using ClearDB to host the MySQL database of my Ruby on Rails application.我正在使用 ClearDB 来托管我的 Ruby on Rails 应用程序的 MySQL 数据库。 Today I observed that the id's of the tables, are jumping on steps of 10, starting on 1: 1, 11, 21, 31, 41.. I searched, and found this:今天我观察到表的 id 以 10 的步长跳跃,从 1: 1, 11, 21, 31, 41.. 我搜索,发现了这个:

"I'd guess that your auto_increment_increment is set to something else than 1 because of replication. With replicated tables one cannot use 1 because of potential key collisions." “我猜你的 auto_increment_increment 由于复制而设置为 1 以外的其他值。对于复制表,由于潜在的密钥冲突,不能使用 1。”

And on the ClearDB forum I found the same answer.. Ok, but the problem is: if id jumps 10 by 10, won't it increases very fast achieving the integer limit of 11 digits very fast?在 ClearDB 论坛上,我找到了相同的答案.. 好的,但问题是:如果 id 以 10 为单位跳动 10,它会不会很快增加,从而非常快地达到 11 位的整数限制? What happens if this situation occurs?如果发生这种情况会怎样? The id's go to 2, 12, 22, 32, 42, starting on 2, then on 3..?? id 转到 2, 12, 22, 32, 42,从 2 开始,然后是 3..??

Does someone here that uses ClearDB can answer me, please?请这里使用 ClearDB 的人可以回答我吗?

The ID will not wrap around it would conflict with their leader to leader replication scheme. ID 不会环绕它会与他们的领导者到领导者复制方案冲突。

It does shorten the Id sequence but only by one digit.它确实缩短了 Id 序列,但只缩短了一位。 If your going to have more than 9,999,999,999 rows, then ClearBD is not the plan for you.如果您将拥有超过 9,999,999,999 行,那么 ClearBD 不适合您。 As your going to hit a lot of their other limits before the row limit.因为您将在行限制之前达到许多其他限制。

To overcome this problem you have to upgrade plan, the provided user can not change the environment variable auto_increment .为了克服这个问题,你必须升级计划,提供的用户不能改变环境变量auto_increment After upgrading to super plan, the user can have all the DBA privileges.升级到超级计划后,用户可以拥有所有的 DBA 权限。 After upgrading run the query below升级后运行下面的查询

ALTER TABLE table_name AUTO_INCREMENT = start_value; ALTER TABLE table_name AUTO_INCREMENT = start_value;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM