Eli*_* Mx 9 sqlite performance clustered-index
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;
Run Code Online (Sandbox Code Playgroud)
这段代码在我的机器上大约需要0.9秒,并创建一个占用392K的db文件.如果我将第二行更改为,则这些数字变为1.4秒和864K
create table person_id(person_id integer nonclustered primary key);
Run Code Online (Sandbox Code Playgroud)
为什么会这样?
小智 0
[仅作为一个想法]
也许当您明确指定将整数列作为聚集键时,它就会这样做。但是,当您告诉它不要使用整数列时,它仍然会在幕后创建索引,但会选择不同的数据类型来执行此操作(假设是两倍大)。然后,每个条目都必须引用表中的记录,这样,大小就会呈爆炸式增长。
| 归档时间: |
|
| 查看次数: |
19115 次 |
| 最近记录: |