Dropping a SQLite database index and then adding it back on
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 data 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).
上一篇: SQLite插入:内存:性能