使用(顺序)GUID是唯一可行的替代数据库生成的ID? [英] Is using a (sequential) GUID the only viable alternative to a database generated ID?

查看:175
本文介绍了使用(顺序)GUID是唯一可行的替代数据库生成的ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用Entity Framework 5 Code First方法将我们的MS-Access数据库迁移到SQL Server Compact 4.0。我们发现使用数据库生成的整数ID是非常慢的,为了使它更糟,延迟随着数据库的大小成指数增长。这使得使用Identity列不可能,并且看起来在SQL Server Compact 4.0中与Entity Framework配对中存在此功能的错误实现。

We are migrating our MS-Access database to SQL Server Compact 4.0 using the Entity Framework 5 Code First approach. We found that using Database generated Integer ID's is very slow and to make it worse, the delay increases exponentially with the size of the database. This makes using an Identity column impossible and it seems there is a bad implementation of this feature in SQL Server Compact 4.0 paired with the Entity Framework.

因此,我们运行了一些测试并发现使用客户端生成的键速度op插入至少20次,插入的指数增加消失。

So, we ran some tests and found that using a client side generated key speeds op insertion by at least 20 times, the exponential increase in insertion disappears.

现在我们正在寻找一个最好的方法生成客户端ID。使用GUID似乎是最安全的选择,但我读到,这负面影响读取操作。有没有使用客户端生成的自动递增的整数的策略?

Now we are looking at a the best way to generate client side ID's. Using GUID's seems the most secure option, but I read that this negatively impacts read actions. Is there a strategy in using auto-incremented Integers that are client side generated?

编辑:
我将调查导致问题的潜在问题。在同一时间,我的真正的问题可以回答吗? : - )

I will investigate the underlying problem that lead to the question further. In the mean time can my real question be answered please? :-)

EDIT2:
这是非常恼火的,没有人似乎相信使用auto-id与EF和SQL Server compact 4.0是如此缓慢的断言。我发布了一个单独的问题

推荐答案

如果您使用EF移动大量数据,你做错了。使用ADO.NET,例如改为BULK COPY方法(使用SQL CE使用SqlCeUpdateableRecord)。您可以使用我的SqlCeBulkCopy库来节省一些编码工作。

If you are moving large amounts of data with EF, you are doing it wrong. Use ADO.NET, and for example a BULK COPY approach instead (with SQL CE use SqlCeUpdateableRecord). You could use my SqlCeBulkCopy library to save some coding effort.

这篇关于使用(顺序)GUID是唯一可行的替代数据库生成的ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆