On 8/4/16, Wade, William <bill.w...@dnvgl.com> wrote:
>
> I believe that with SQLite, if you don't specify WITHOUT ROWID your "real"
> record order is based on rowid,

Correct

>
> In principle, indices can be created by writing the needed information
> (index key, record position) in the original order, and then sorting that
> into key-order. That can be done with many less random seeks (merge sorts
> involve mostly sequential reads and writes). I don't know if, or when,
> SQLite does that.
>

SQLite runs CREATE INDEX commands using an external merge sort, which
is what I think you are eluding to above.

But if the index already exists, and you are merely inserting new rows
into the table, then each index entry is inserted separately.  Each
such insert is an O(logN) operation.  Such isolated inserts typically
involve a lot of disk seeks and write amplification.  That is why we
recommend that you populate large tables first and then run CREATE
INDEX, rather than the other way around, whenever practical.

-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to