Subject | RES: [firebird-support] Internal Firebird question. |
---|---|
Author | Fabiano |
Post date | 2012-05-21T18:32:32Z |
Forget!
You right, it uses free space when the page are touched.
I make a mistake. The old data continues on datapage but pointers are
updated. Now it shows me 3 records.
Thanks!
De: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] Em nome de Dmitry Kuzmenko
Enviada em: segunda-feira, 21 de maio de 2012 15:01
Para: firebird-support@yahoogroups.com
Assunto: Re: [firebird-support] Internal Firebird question.
Hello, Fabiano!
Monday, May 21, 2012, 9:08:04 PM, you wrote:
F> I have a question about how Firebird internally updates a record.
it uses versioning.
F> Insert into test(cod, name) values (1, 'Big description 1');
F> Insert into test(cod, name) values (2, 'Big description 2');
F> Insert into test(cod, name) values (3, 'Big description 3');
well, 3 records in table.
F> Delete from teste where cod=2;
here engine created new version named as "delete stub" for one of the
records. It keeps "old" record because it can be still visible and
required for running snapshot transactions, even if they are not
exist now.
F> Whell, next I insert a new record:
F> Insert into test(cod, name) values (2, 'Small 2');
4-th record.
F> After that I reinspect the FDB file and it not REUSE the old record that
F> contains "Big description 2". It stays here and a NEW record was create
to
F> hold the new record 2 that are SMALL than old record.
yes. deleted or updated records are "new versions", and "old versions"
can be considered garbage and removed from pages only when engine
will be sure that these "old versions" are not needed for any
running transactions.
Old versions will be cleared during select or update statement that
will "touch" this records.
F> Why? Why Firebird does not reutilize that space?
see below.
F> I tested with only one connection in a test database with only this
table.
versioning works always, there is no "single-user mode" in the
Firebird engine.
please read
http://www.firebirdsql.org/en/multi-version-concurrency-control/
http://en.wikipedia.org/wiki/Multiversion_concurrency_control
http://blogs.teamb.com/craigstuntz/2005/02/18/2699/
http://blogs.teamb.com/craigstuntz/2004/06/22/587/
etc.
--
Dmitry Kuzmenko, www.ib-aid.com
[Non-text portions of this message have been removed]
You right, it uses free space when the page are touched.
I make a mistake. The old data continues on datapage but pointers are
updated. Now it shows me 3 records.
Thanks!
De: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] Em nome de Dmitry Kuzmenko
Enviada em: segunda-feira, 21 de maio de 2012 15:01
Para: firebird-support@yahoogroups.com
Assunto: Re: [firebird-support] Internal Firebird question.
Hello, Fabiano!
Monday, May 21, 2012, 9:08:04 PM, you wrote:
F> I have a question about how Firebird internally updates a record.
it uses versioning.
F> Insert into test(cod, name) values (1, 'Big description 1');
F> Insert into test(cod, name) values (2, 'Big description 2');
F> Insert into test(cod, name) values (3, 'Big description 3');
well, 3 records in table.
F> Delete from teste where cod=2;
here engine created new version named as "delete stub" for one of the
records. It keeps "old" record because it can be still visible and
required for running snapshot transactions, even if they are not
exist now.
F> Whell, next I insert a new record:
F> Insert into test(cod, name) values (2, 'Small 2');
4-th record.
F> After that I reinspect the FDB file and it not REUSE the old record that
F> contains "Big description 2". It stays here and a NEW record was create
to
F> hold the new record 2 that are SMALL than old record.
yes. deleted or updated records are "new versions", and "old versions"
can be considered garbage and removed from pages only when engine
will be sure that these "old versions" are not needed for any
running transactions.
Old versions will be cleared during select or update statement that
will "touch" this records.
F> Why? Why Firebird does not reutilize that space?
see below.
F> I tested with only one connection in a test database with only this
table.
versioning works always, there is no "single-user mode" in the
Firebird engine.
please read
http://www.firebirdsql.org/en/multi-version-concurrency-control/
http://en.wikipedia.org/wiki/Multiversion_concurrency_control
http://blogs.teamb.com/craigstuntz/2005/02/18/2699/
http://blogs.teamb.com/craigstuntz/2004/06/22/587/
etc.
--
Dmitry Kuzmenko, www.ib-aid.com
[Non-text portions of this message have been removed]