Articles WARNING! How to "inflate" Firebird database with temporary blobs!

emailx45

Местный
Регистрация
5 Май 2008
Сообщения
3,571
Реакции
2,439
Credits
574
How to "inflate" Firebird database with temporary blobs
[SHOWTOGROUPS=4,20]
This is one of the don't-do-this articles - just as an example. If you encounter the abnormal growth of your Firebird database, check that you did not write a stored procedure, trigger or execute block, which uses BLOBs concatenation.
In some cases, Firebird stores temporary BLOBs inside the database file, so it grows very very quickly.

The following example creates a lot of small temp blobs, which are stored in the database file, so it will "inflate" Firebird database by ~2Gb (Be careful and don't run it on production or important databases!) :

Код:
execute block
returns (
    BLB blob)
as
declare BLB1 blob;
declare I integer;
begin
  I = 0;
  BLB = 'blabla';
  BLB1 = cast('blablablablablablablablablablablablablabla' as blob);
  while (I < 10000) do
  begin
    BLB = BLB || BLB1;
    I = I + 1;
  end
  suspend;
end

Firebird keeps temporary blobs until the commit (or rollback) of the transaction. If you commit the transaction and then launch code once again, you will notice that the database file will not grow - this is due to the fact that space for temporary BLOBs inside the database is reused.
[/SHOWTOGROUPS]