I am inserting a large number of records into a SQLite database on Android. To improve insert times, I am considering creating the index on the table after dat开发者_如何学Pythona has been fully added.
My question is, at what point does the database actually build the index against values on the table? Does it happen as soon as I issue the SQL statement (create index index_name on table ...
), or can the database defer it until the first query arrives?
Thanks, Ranjit
It creates the index immediately you issue the create index
command. The relevant code is in sqlite3CreateIndex
and this will create the index and write it to disk (except for the special case where it's called as part of a database open operation but that's not the case when a user creates an index).
精彩评论