On Aug 13, 2010, at 8:41 PM, Max Vlasov wrote:

> On Fri, Aug 13, 2010 at 1:38 PM, Max Vlasov <max.vla...@gmail.com>  
> wrote:
>
>>
>> I can approximately calculate, how big the new database will grow. Is
>>> there a way to tell SQLite to reserve an inital space or numer of  
>>> pages
>>> instead of letting the database file grow again and again?
>>>
>>
>>
>> Thought about this recently. Another idea is to tweak VFS. Since  
>> xWrite
>> method is supposed to accept iOfst that is bigger than the current  
>> file
>> size, one can check whether the new write query is going to  
>> allocate new
>> space for the file (vs internal space writing), and before actual  
>> call make
>> prior call of the same function writing for example a single zero  
>> byte a
>> little far and after that perform the original request.

The fossil tip at present supports the SQLITE_FCNTL_CHUNK_SIZE
argument to sqlite3_file_control(). To allocate space
in 1MB chunks:

void setOneMBChunkSize(sqlite3 *db){
   int szChunk = 1024*1024;
   sqlite3_file_control(db, "main", SQLITE_FCNTL_CHUNK_SIZE,  
(void*)&szChunk);
}

 From that point on, connection "db" extends and truncates
the db file in 1MB chunks.

Works on unix and win32.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to