Question

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.

  1. 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?
  2. 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.
Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top