主键设置,总的来说int;Guid/string

Posted yangzhenping

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了主键设置,总的来说int;Guid/string相关的知识,希望对你有一定的参考价值。

主键设置,总的来说int>Guid/string

 

一般设置int为主键可以有更高的效率


mysql:


 

http://venublog.com/2010/04/19/choosing-the-right-data-type-makes-a-big-difference/
http://venublog.com/2010/04/20/int-and-string-data-comparison-difference-in-performance-because-of-quotes/
http://www.karafilis.net/sql-indexing-part4/

 

mssql:


http://www.sql-server-performance.com/2007/datatypes/
http://bytes.com/topic/sql-server/answers/143943-int-versus-char-primay-key-performance
http://www.codeproject.com/Articles/22853/SQL-Server-Performance-Tips-and-Guidelines
https://www.simple-talk.com/sql/t-sql-programming/searching-for-strings-in-sql-server-databases-/
http://www.informit.com/articles/printerfriendly/25862

 

How to choose?


http://blog.codinghorror.com/primary-keys-ids-versus-guids/
http://databases.aspfaq.com/database/what-should-i-choose-for-my-primary-key.html
http://www.informit.com/articles/printerfriendly/25862
http://krow.livejournal.com/497839.html

 

others:


http://programmers.stackexchange.com/questions/189026/why-is-the-usage-of-string-keys-generally-considered-to-be-a-bad-idea
http://www.dbforums.com/showthread.php?1666783-int-vs-varchar-columns-performance
http://sqlinthewild.co.za/index.php/2011/02/15/are-int-joins-faster-than-string-joins-2/
http://www.codeproject.com/Articles/17512/DataRow-Indexing-Performance-Integer-vs-String

以上是关于主键设置,总的来说int;Guid/string的主要内容,如果未能解决你的问题,请参考以下文章

mysql设置主键为自增,主键为int类型,最大值只能设置成255吗

项目中的那些事---踩过的数据库坑

SQ数据库中怎样设置自增主键?

Ef core 如何设置主键

Ef core 如何设置主键

MYSQL其中某一列(int类型),我想按照以主键生成策略一样生成,请问如何实现?