Subject Re: [firebird-support] gfix -sweep Versus gbak -g
Author Thomas Steinmaurer
> Hello folks!
>
> I’m Brazilian so sorry about some mistakes in the text below…
>
> We have a new (~2 years old) system developed using Firebird 2.5.1
> Classic. We use Delphi XE2 + Datasnap with a strict transaction control,
> only 3 or 4 places on the application server control de entire
> transaction scope.
>
> At the beginning of this project we developed a “task manager” (will
> call TM) that runs a daily backup (gbak –g) on the production database
> and then it restores that backup into a new database for testing
> purpose. Our clients are not 24x7 usage (Accounting purpose software) so
> this task starts at 10PM. The intent of this is:
>
> *Make a backup;
>
> * Collect the garbage generated;
>
> * Test if a corruption is found (If I can’t backup AND restore that
> database and alert is raised and the system stops for maintenance);
>
> When a new version is released it is MANDATORY (by the TM) doing a
> backup and restore cycle.
>
> All runs fine those years but last week our big client (140 simultaneous
> users, 16Gb database) tell us the system is running slow and slow. We
> test a report that run in FIRST time in 10 seconds. SECOND try and 40
> seconds! 3 and 1 minute and 40 seconds. I disconnect all users and ran a
> backup, nothing.
>
> Ran a gstat ans discovered that HAS old records versions what is odd to
> me because I always presume that running a gbak –g will collect all
> garbage AND discard old record versions. Then I run gfix –sweep and 10
> minutes later the system runs smooth with every report try running in 5
> seconds.
>
> Now my question: Does gbak –g do not remove old record version?

It doesn't. Providing the -g switch means, *suppressing* garbage collection.

> I must
> run gfix –sweep regularity (In a daily basis)? Besides server slow down,
> are any danger involving run gfix –sweep in a production database?

I vaguely remember one or two issues, especially under high load, but
I'm not entirely if my memory serves me correctly. You might search the
Firebird tracker. Sweep also might not do the job efficiently from a
"removing garbage" POV, if (long-running) active transactions are
hanging around while a sweep is kicked off.

If you start from a freshly restored database via gbak, there is no
garbage in the database, thus no need to run e.g. a sweep after the restore.

An usual practice, if gbak -g *is* used, to run a manual scheduled sweep
once a day under low load.



--
With regards,
Thomas Steinmaurer
http://www.upscene.com/

Professional Tools and Services for Firebird
FB TraceManager, IB LogManager, Database Health Check, Tuning etc.