ID生成的分片数据库(Azure的联合数据库)数据库、分片、ID、Azure

2023-09-04 02:11:31 作者:单眼皮男孩

我一直在寻找一些文章或指导做好最佳实践ID生成(为联合/主键)为Azure的联邦数据库,并没有发现任何令人信服的。联合表不支持标识列,所以在我看来,该ID的唯一的实用型是一个GUID,因为试图集中创建和使用一个BIGINT会在应用程序中的单点故障。我的主要关注的是使用的GUID超过BigInts对性能的影响(特别是对索引表)。

I have been looking for some articles or guidence on best practice for id generation (for the federated/primary key) for Azure Federated databases and haven't found anything compelling. Federated tables don't support identity columns, so it seems to me that the only practical type of id is a GUID, as trying to centrally create and use a BigInt creates a single point of failure in the app. My chief concern is the performance implications of using GUIDs over BigInts (particularly for indexing the tables).

有没有什么建议/最佳实践(或现有的库),以创建一个分布式系统唯一BigInts(或者我应该不用担心使用GUID的性能影响?)。

Is there any recommended/best practice (or existing libraries) to create unique BigInts for a distributed system (or should I not worry about the performance implications of using GUIDs?).

[更新]

在读了很多关于这一点,在我看来,关键的一代人将在Azure中的一个问题。由于按照本blog从微软发布时,建议使用的GUID作为联合键。但他们没有提及的是对联邦表的所有索引(包括聚集索引)必须包含联合键。这意味着,所有这些指标将包含一个GUID,这会杀了插入性能。

Having read a lot more about this since posting the question, it seems to me that key generation will be a problem in Azure. As per the this blog post from Microsoft, it is recommended to use GUIDs as Federated key. However they fail to mention that all indexes (including clustered indexes) on Federated tables have to contain the federated key. This means that all these indexes will contain a GUID, which is going to kill insert performance.

替代好像是用一个centeralized密钥生成服务(如上述由Simon以下),其具有其自身的缺点在身为潜在瓶颈和失败的中心点条款。

The alternative seems to be using a centeralized key generation service (as mentioned by Simon below) which has its own drawbacks in terms of being a potential bottle neck and central point of failure.

我还以为那里会更多地指导做好这个来自微软的肯定,这是一个问题,每个人都建立联合表将面对!

I would have thought there would have been more guidence on this from Microsoft as surely this is an issue that everyone creating federated tables will face!

在平衡我已经决定去与centeralized密钥生成服务,但它确实关心我一点点。如果任何人有一些魔术技巧我很乐意听到它(或让我知道如果我失去了一些东西明显)!

On balance I have decided to go with a centeralized key generation service, but it does concern me a little bit. If anyone has some magic technique I would love to hear it (or let me know if I am missing something obvious) !

推荐答案

您可以创建在使用各种技术的应用的序列,但它们是因为的分布式特性并不简单。一说是使用 Blob存储和preconditions 的相当不错。

You could create sequences in the application using a variety of techniques, but they are not straightforward because of the distributed nature. One that is quite good is using blob storage and preconditions.

根据项目进度,你可能想使用的 SQL 2012 SEQUENCE ,并把所有的序列在小非联邦数据库。 SEQUENCE不可用的但的在SQL Azure上。

Depending on your project schedule you may want to use the SQL 2012 SEQUENCE and put all your sequences in a small non-federated database. SEQUENCE is not available yet on SQL Azure.

 
精彩推荐
图片推荐