Subject Re: [firebird-support] How does sweeping works?
Author Ann W. Harrison
Daniel Vogelbacher wrote:
>
> If 1000 rows deleted by a commited transaction, is the space available
> immediately or only after GC runs?

The space becomes available after all transactions that could read
the deleted rows have committed. Consider this case:

Transaction 1 starts:
select count(*) from t1;

21

Transaction 2 starts:
delete from t1;
commit;

Transaction 3 starts:
select count(*) from t1;

0

Transaction 1 continues:
select count(*) from t1:

21

The rows that transaction 2 deleted must persist until the end of
Transaction 1 and any other transactions that started before
Transaction 2.

>
> Does the GC starts automatically (configurable?) or/and is it possible to
> start GC manually (without running sweep)?

Garbage collection starts automatically. It runs in three modes, which
are selectable: cooperative, separate thread, and hybrid. Cooperative
garbage collection makes each writing transaction responsible for
cleaning up old record versions when it needs space on a page. The
separate garbage collection thread runs periodically, depending on
system load. The hybrid mode uses cooperative garbage collection when
all of the old record is on the page that had to be written anyway.
If old record versions chain across pages, the record (page?) is put
on a list for the garbage collect thread.

The trade-off among these is not as obvious as it seems. In a heavily
loaded system, the garbage collect thread can starve, leading to a
serious sanitation crisis.

>
> Is GC/sweeping required for fast select queries?

That depends on the load and mix of reads and updates/deletes. But
since it happens automatically, I wouldn't worry about it.


Cheers,

Ann
>