sqlite 如何存储其内容
根据我的 Google 搜索,sqlite 不支持聚集索引(请参阅四:聚集索引),但我不明白的是:
这意味着如果您的索引是 连续的 INTEGER,记录是 物理地布置在数据库中 INTEGER 的顺序是:1 然后 2 然后 3。
- 如果从包含顺序 int 索引的表中删除一些记录,新插入的记录将放在哪里?据我所知,记录int ID只会增长,因此记录将被追加到tail,对吧?是不是说删除的地方都浪费了?
- 在没有顺序INTEGER索引的情况下,sqlite表是堆表吗?即记录将放置在首先找到可用空间的位置。
From what I Google, sqlite does't support clustered indexes(see Four: Clustered Indexes), but what I doesn't understand are:
This means that if your index is
sequential INTEGER, the records are
physically laid out in the database in
that INTEGERs order, 1 then 2 then 3.
- If some records are deleted from a table which contains sequential int index, where the records of the new insertion be placed? From what I know, the records int ID will only grow,so the records will be appended to tail, right? Does it means the deleted places are wasted?
- In the case of no sequential INTEGER index, is the sqlite table a heap table? i.e. the record will be placed where the free space is first found.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1)对,记录会发生在尾部。是的,如果数据库引擎不能轻松地重新使用已删除的位置,则可能会浪费它。当您使用命令 VACUUM 压缩数据库时,未使用的位置将被删除。
2)是的,这样的SQL表是堆表。但索引(任何类型)都是为了访问数据而精确设计的,就像记录已排序一样。索引是链接到记录的排序值。但新记录不一定放置在首先找到可用空间的位置。考虑到未使用的空间和写入二进制数据的时间(在队列中发生比在中间插入更快),它们被放置在数据库引擎填充的位置。
1) Right, records will be happened to tail. Yes, deleted places may be wasted if the database engine cannot re-use it easily. The unused places will be deleted when you compact the database using command VACUUM.
2) Yes such a SQL table is a heap table. But indexes (of any kind) are precisely made to access data as if records were sorted. Indexes are sorted values linked to records. But the new records are not necessarily placed where the free space is first found. They are placed where the database engine fill nice to place them taking into account unused space and time to write the binary data (happening in queue is faster than inserting in the middle).