Joe C
Joe C

Reputation: 2827

Does SQLite optimize the primary key indexing table?

At the link http://sqlite.1065341.n5.nabble.com/create-index-before-or-after-many-inserts-td31426.html, it says creating an indexing table after all rows are inserted is more efficient than creating the indexing table before inserting rows.

I assume SQLite always creates an indexing table for primary keys. Does SQlite delay creating the table when data are inserted?

If SQLite has the table at the beginning, and grows the table during data insertion, does it optimize the table data layout after all data are inserted?

Upvotes: 0

Views: 46

Answers (1)

CL.
CL.

Reputation: 180060

When your primary key is a single column that is autoincrementing, or when you are using a clustered index, there is no separate index. Otherwise, there is.

There is no automatic optimization step after you are finished, because the database cannot know whether you are finished (you could always execute another INSERT). You could try to run VACUUM, but after bulk inserts (without any other changes), the difference, if there is any, is likely to be too small to be noticed.

Upvotes: 1

Related Questions