how to make use of "auto-vacuum" ?

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
freemaker
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 30.05.2009, 04:56

how to make use of "auto-vacuum" ?

Post 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!
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post by trupka »

Do you mean postgresql auto-vacuum or sqlite? Version?
freemaker
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 30.05.2009, 04:56

Post by freemaker »

sqlite3
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post 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).
freemaker
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 30.05.2009, 04:56

Post by freemaker »

trupka: thank you very much! Could you tell me how to set "pragma autovacuum = 1|" of sqlite3 with Zeos ?
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post 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;
Post Reply