Subject Re: about Garbage collection and Sweep Interval
Author Adam
--- In firebird-support@yahoogroups.com, "deepak_cs_mca_2006"
<deepak_cs_mca_2006@...> wrote:
>
> Hi,
>
> I have a query related to garbage collection in firebird.As I know
> there are two ways garbage collection mechanisms
> 1. Explicit: which a user calls by gfix or gbak.
> 2. Implicit: which is performed by firebird itself. From what I have
> learnt on the Internet this happens in many ways
> [a] when executing a select query it encounters on a deleted row in
> the database it performs garbage collection on it
> [b] after the expiry of the sweep interval it runs a separate
> garbage collection thread
>
> Is my understanding about the implicit garbage collection correct?

More or less. As long as you understand that old record versions are
not actually 'garbage' until all other potentially interested
transactions have completed. Also note that there is a difference
between classic and superserver, and a difference between 1.5 and 2.0.

Classic does not have a separate thread, it is all left to the
transaction that stumbles upon it. Superserver in 2.0 has an improved
co-operative mode. In a nutshell, the transaction that stumbles upon
it sees whether it can make the change immediately or if it is going
to take a while to load pages from disk first. If it takes too long,
it leaves it for the garbage collection thread.

> Does it happen in one of the two ways or both ways?

Both.

> I would also ask
> how is the sweep interval calculated.
>

It defaults to 20000 transactions, but it is set in your database. You
can set it to whatever value you like. I can't tell you what is so
magical about 20000 though. It can also be turned off (set to 0) so it
never runs. This can be useful if you have a nightly downtime or at
least an off peak time. You can use the task scheduler of your OS to
call sweep during this time.

Adam