begin transaction;
create table person_id(person_id integer primary key);
insert into person_id values(1);
... snip ...
insert into person_id values(50000);
commit;
此代码在我的机器上大约需要 0.9 秒,并创建一个占用 392K 的 db 文件。如果我将第二行更改为,这些数字将变为 1.4 秒和 864K
create table person_id(person_id integer nonclustered primary key);
为什么会这样?
最佳答案
在 DBA StackExchange 上可以找到这个问题的一个很好的答案:https://dba.stackexchange.com/questions/7741/when-should-a-primary-key-be-declared-non-clustered/7744#7744
关于performance - 集群主键与非集群主键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2138507/