Mr.Mindor
Mr.Mindor

Reputation: 4129

Is it possible to force Sqlite to reserve space when file size grows?

Due to legacy design decisions we are using SqLite over file shares. We have a central service that writes configurations to the SqLite.dbs on remote machines. Those machines treat the databases as read only so we avoid most problems with synchronization. Some of these machines are accessed through very slow connections. I am working to improve the performance of this configuration process and I seem to have hit a bottleneck with inserts that cause an increase in the file size.

On our slowest connection we jump from about 100ms to 10's of seconds or even a minute and a half(depending on other network traffic):

2011-11-22 15:13:07,766 --insert uses free space
2011-11-22 15:13:07,844 --insert uses free space
2011-11-22 15:13:07,922 --insert uses free space
2011-11-22 15:13:08,000 --insert uses free space
2011-11-22 15:13:51,035 --free space gone, file size grows to fit
2011-11-22 15:14:16,298 --free space gone, file size grows to fit
2011-11-22 15:14:38,876 --free space gone, file size grows to fit

I know in SqlServer it is possible to set an autogrowth value to keep an amount of padding available. Is it possible to change this behavior from grow-to-fit to grow-with-reserve?

If it matters, the configuration service is written in C#. Database access is done through NHibernate (wrapped in a layer written by those who left us this legacy) and references System.Data.Sqlite.

Upvotes: 1

Views: 960

Answers (1)

MPelletier
MPelletier

Reputation: 16687

Yikes. The only thing I see would be to set the page_size to the largest (or most likely) value possible (and allowed). The upper limit is 2^16 bytes.

Upvotes: 1

Related Questions