主键作为 INT,全局键作为 GUID 以提高性能
在决定表的键时,为表设置一个 INT 主键(自动增量)并为数据库范围设置一个 GUID(除了 INT 之外)是否合适?考虑到表 DML 语句会更多,在 INT 上操作会更快,而如果要执行任何泛数据库 DML 语句,GUID 就会派上用场。请注意,我正在使用 MySQL,以防万一。请大家发表意见。
While deciding upon the keys for a table, is it good to have an INT primary key (autoincrement) for the table and a GUID (in addition to the INT) for the scope of the database? Given that there will be more table DML statements it will be faster to operate on INT whereas if any pan-database DMLs statements are to be executed, GUID will come handy. Please note I am using MySQL, just in case if it matters. Please opine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我之前已经这样做过并且成功运行:正如您所指出的,使用
GUID
意味着我们在将一个数据库中的数据与另一个数据库合并时避免了冲突,并且int< /code> 为我们提供了高效的连接等。当您处理 OLAP 时,我绝不会使用 GUID 作为键,因为这会影响性能。
I've done that before and it worked successfully: as you point out, using a
GUID
meant that we avoided conflicts when merging, say, data from one database with another, and theint
provided us with efficient joining etc. I would just never use aGUID
as a key when you're dealing with OLAP, as that will performance.