Subject Re: [firebird-support] Garbage Collection question/problem
Author Helen Borrie
At 19:47 22/08/2008, you wrote:
>Hello,
>
>I use Firebird embedded 2.0.3 on Windows XP and as far as I know,
>garbage collection is disabled or nearly ineffective for embedded
>databases.
>
>I tried gfix -sweep but the database size does not change by 1 byte.

No, the database size never gets smaller. Once garbage has been dealt with, the space those obsolete records were using is released for re-use.


>The only solution I've found so far is a full backup/restore
>procedure (gbak -B/gbak -R).
>
>Am I overlooking something ?

Yes. Sweep and garbage collection are not meant to make databases smaller and they never do.

>Why doesn't gfix -sweep works ?

Sweep works. So does the background GC worker thread. But they won't remove garbage that remains interesting to active transactions.

>Is there a better way to force garbage collection for embedded databases
>(connection string option, command line utility, ...) ?

gfix -sweep *is* a command-line utility. And you can't "force" garbage collection to get rid of obsolete records that the database engine thinks you want to keep.

Just get used to the idea of a database server that manages its own disk space. When it can't find a page belonging to a table or index that has enough space for a write, it gets a fresh page from the OS. So, in early days, your database file will seem to grow more than the amount of data you put there. If you write applications in such a way that garbage is dealt with in a regular and timely manner, your database will reach an equilibrium point where space is reused efficiently and database growth will reflect data growth.

./heLen