| 1 |
----------------------------------------------------------- |
| 2 |
Firebird 2.0 garbage collector |
| 3 |
----------------------------------------------------------- |
| 4 |
|
| 5 |
Engine knows about each record versions produced by update\delete statement |
| 6 |
and can remove them as soon as oldest snapshot transaction (OST) allowed this. |
| 7 |
This eliminates the need to read pages with these versions again by user request |
| 8 |
(i.e. SELECT COUNT(*) FROM table) and avoids situation when these versions are |
| 9 |
never read (of course sweep always removed all unused record versions). Also |
| 10 |
there is high probability that needed pages still reside in the buffer cache |
| 11 |
thus there are less additional disk IO needed. |
| 12 |
|
| 13 |
Between notifying garbage collector about page with unused versions and time |
| 14 |
when garbage collector will read this page new transaction can update record |
| 15 |
and garbage collector can't cleanup this record if this new transaction number |
| 16 |
is above OST or still active. In this case engine again notifies garbage collector |
| 17 |
with this page number and it will clean up garbage at some time later (old garbage |
| 18 |
collector will "forget" about this page until user reads it again) |
| 19 |
|
| 20 |
Both cooperative and background garbage collection are now possible. To manage it |
| 21 |
new configuration parameter "GCPolicy" was introduced. It can be set to: |
| 22 |
|
| 23 |
a) cooperative - garbage collection performed only in cooperative mode, such |
| 24 |
as before IB6. Each user request is responsible for removing unused record |
| 25 |
versions. This is how engine works before IB6. This is only option for |
| 26 |
Classic Server mode. Engine doesn't track versions produced as result of |
| 27 |
update and delete statements |
| 28 |
|
| 29 |
b) background - garbage collection performed only by background thread, such |
| 30 |
as in IB6 and later. No user requests remove unused record versions. |
| 31 |
Instead user request notifies dedicated garbage collector thread with page |
| 32 |
number where unused record version is detected. Also engine remembers page numbers |
| 33 |
where update\delete statement created backversions. |
| 34 |
|
| 35 |
c) combined - both background and cooperative garbage collection are performed. |
| 36 |
|
| 37 |
Default is "combined" for SuperServer. ClassicServer ignores this parameter and |
| 38 |
always works in "cooperative" mode |