Page 1 of 1

how to make use of "auto-vacuum" ?

Posted: 03.06.2009, 15:42
by freemaker
:)
Hi, friend!
I added 1k records in the test table, and then I delete the records. I found the file size of db did not decrease.

Could you tell me how to make the "auto-vacuum" work ? Thanks!

Posted: 03.06.2009, 16:19
by trupka
Do you mean postgresql auto-vacuum or sqlite? Version?

Posted: 03.06.2009, 16:23
by freemaker
sqlite3

Posted: 03.06.2009, 19:44
by trupka
Sqlite3 database must be prepared for autovacuuming when created, before any tables (metadata) are created (pragma autovacuum = 1|. Otherwise autovacuum won't work. From zeos point of view, autovacuum will run every time commit is issued (when pragma autovacuum = 1).

Posted: 04.06.2009, 10:59
by freemaker
trupka: thank you very much! Could you tell me how to set "pragma autovacuum = 1|" of sqlite3 with Zeos ?

Posted: 04.06.2009, 14:11
by trupka
freemaker wrote:Could you tell me how to set "pragma autovacuum = 1|" of sqlite3 with Zeos ?
Sample follows:

Code: Select all

var
	isNewDB: boolean;
begin
	isNewDB := not FileExists(ZConnection1.Database);
    ZConnection1.AutoCommit := true; 
    ZConnection1.Connect; // will create database file if doesn't exist
    if isNewDB
    then begin
        ZConnection1.ExecuteDirect('pragma auto_vacuum = 1');
        ZConnection1.ExecuteDirect('create table test(id integer, name varchar(25))');
    end;