Hi,
I am using EF with a SQL Lite DB which has 'Journal Mode=WAL' set in the connection string as there are a few processes that could be accessing the DB.
I would like to compact the DB on startup of any of processes and have no clue if that is safe to do or what the best setting is to do that. (connection string/code/??)
Any advice would be greatly appreciated.
John.
Compact DB on startup
Re: Compact DB on startup
Please execute the "VACUUM" statement to compact your SQLite database:
Code: Select all
using (SQLiteCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "VACUUM";
cmd.ExecuteNonQuery();
}
Re: Compact DB on startup
Which way is best to use? Code (as in the example above) or with connctionsting - AutoVaccuum = Full?Shalex wrote:Please execute the "VACUUM" statement to compact your SQLite database:Code: Select all
using (SQLiteCommand cmd = conn.CreateCommand()) { cmd.CommandText = "VACUUM"; cmd.ExecuteNonQuery(); }
What is the difference between these two ways?
Re: Compact DB on startup
Wish to know which method is considered the best and fastestFretek wrote:Which way is best to use? Code (as in the example above) or with connctionsting - AutoVaccuum = Full?Shalex wrote:Please execute the "VACUUM" statement to compact your SQLite database:Code: Select all
using (SQLiteCommand cmd = conn.CreateCommand()) { cmd.CommandText = "VACUUM"; cmd.ExecuteNonQuery(); }
What is the difference between these two ways?
Re: Compact DB on startup
Sorry for the delay.
The "AutoVaccuum=Full;" connection string parameter turns on the following pragma: http://sqlite.org/pragma.html#pragma_auto_vacuum.
The SQLiteCommand with the "VACUUM" command text calls this command: http://sqlite.org/lang_vacuum.html.
The "AutoVaccuum=Full;" connection string parameter turns on the following pragma: http://sqlite.org/pragma.html#pragma_auto_vacuum.
The SQLiteCommand with the "VACUUM" command text calls this command: http://sqlite.org/lang_vacuum.html.