Is there a way to pre allocate my SQLite database to a certain size? Currently I'm adding and deleting a number of records and would like to avoid this over head at create time.
+1
A:
There is a hack - Insert a bunch of data into the database till the database size is what you want and then delete the data. This works because:
"When an object (table, index, or trigger) is dropped from the database, it leaves behind empty space. This empty space will be reused the next time new information is added to the database. But in the meantime, the database file might be larger than strictly necessary."
Naturally, this isn't the most reliable method. (Also, you will need to make sure that auto_vacuum is disabled for this to work). You can learn more here - http://www.sqlite.org/lang_vacuum.html
Sam
2009-05-05 22:16:52
As I said in my question, this is what I currently doing. But thanks for the auto_vacuum hint!
paul
2009-05-05 22:39:41
Glad to help. Another thing that would help you slightly improve the performance of the SQLite db is to make sure that you defragment the db file (especially if you are using windows).
Sam
2009-05-06 12:09:41