🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #11221

Re: Bulk inserts makes GDB grow

#11221
From: Bill Todd
Date: Wed, 11 Dec 2002 22:27
160 lines
5299 bytes
The only other thing to try is to run a sweep instead of the SELECT
query to garbage collect the deleted records. 

On Wed, 11 Dec 2002 15:52:12 +0100, "Dietrich v. Witzleben"
<info@witzleben-edv.de> wrote:

>Hi,
>
>Committing didn't help. GDB is still growing, closing the GDB takes up to 6
>minutes!
>
>Is there anything I have to set when creating the GDB (PageSize ...)
>
>
>Here is my code:
>
>  Filename := 'c:\DATAFILE.RAW';
>
>  F_MAIN.TRANS.starttransaction;
>  IBSQL1.Sql.clear;
>  IBSQL1.Sql.Text := 'delete from STOCK;';
>  IBSQL1.execQuery;
>  F_MAIN.TRANS.Commit;
>
>  F_MAIN.TRANS.starttransaction;
>  IBQuery1.sql.clear;
>  IBQuery1.sql.add('select * from STOCK');
>  IBQuery1.open;
>  IBQuery1.close;
>
>  IBSQL1.Sql.clear;
>  IBSQL1.Sql.add('Insert into STOCK (');
>  for x:=0 to IBQuery1.FieldDefs.count-2 do begin
>    IBSQL1.Sql.add(IBQuery1.FieldDefs[x].name+',');
>  end;
>  IBSQL1.Sql.add(IBQuery1.FieldDefs[IBQuery1.FieldDefs.count-1].name+')
>values (');
>  for x:=0 to IBQuery1.FieldDefs.count-2 do begin
>    IBSQL1.Sql.add(':'+IBQuery1.FieldDefs[x].name+',');
>  end;
>
>IBSQL1.Sql.add(':'+IBQuery1.FieldDefs[IBQuery1.FieldDefs.count-1].name+')');
>
>  RawInput := TIBInputRawFile.Create;
>  try
>    RawInput.FileName := FileName;
>    IBSQL1.BatchInput(RawInput);
>  finally
>    RawInput.Free;
>  end;
>
>  F_MAIN.TRANS.Commit;
>
>
>
>
>
>"Bill Todd" <bill@notthis.dbginc.com> schrieb im Newsbeitrag
>news:66favuo7kh7r0on6lc1r6hb8qikf6k8qaq@4ax.com...
>>
>>
>> On Mon, 9 Dec 2002 23:00:10 +0100, "Dietrich v. Witzleben"
>> <info@witzleben-edv.de> wrote:
>>
>> >Sorry,
>> >
>> >it's still growing. I'm using Interbase 6.016 / IBExpress
>> >
>> >Here is the exact code. The imported RAW-table is 1.488K small. With 10
>> >deletes/Inserts it is growing about 8MB.
>> >Also, it takes a long time (6 min) to close the GDB!!
>> >If I do a backup/restore it shrinks to it's original size.
>> >
>> >
>> >  F_MAIN.TRANS.starttransaction;
>> >
>> >  IBSQL1.Sql.Text := 'delete from stock;';
>> >  IBSQL1.execQuery;
>>
>> Look at my example again. You need to Commit and StartTransaction
>> here.
>>
>> >  IBQuery1.sql.clear;
>> >  IBQuery1.sql.add('select * from stock');
>> >  IBQuery1.open;
>> >  IBQuery1.close;
>> >
>> >  F_MAIN.TRANS.Commit;
>> >
>> >  F_MAIN.TRANS.starttransaction;
>> >
>> >  IBQuery1.sql.clear;
>> >  IBQuery1.sql.add('select * from stock');
>> >  IBQuery1.open;
>> >  IBQuery1.close;
>> >
>> >  IBSQL1.Sql.clear;
>> >  IBSQL1.Sql.add('Insert into stock (');
>> >  for x:=0 to IBQuery1.FieldDefs.count-2 do begin
>> >    IBSQL1.Sql.add(IBQuery1.FieldDefs[x].name+',');
>> >  end;
>> >  IBSQL1.Sql.add(IBQuery1.FieldDefs[IBQuery1.FieldDefs.count-1].name+')
>> >values (');
>> >  for x:=0 to IBQuery1.FieldDefs.count-2 do begin
>> >    IBSQL1.Sql.add(':'+IBQuery1.FieldDefs[x].name+',');
>> >  end;
>> >
>>
>>IBSQL1.Sql.add(':'+IBQuery1.FieldDefs[IBQuery1.FieldDefs.count-1].name+')')
>;
>> >
>> >  RawInput := TIBInputRawFile.Create;
>> >  try
>> >    RawInput.FileName := FileName;
>> >    IBSQL1.BatchInput(RawInput);
>> >  finally
>> >    RawInput.Free;
>> >  end;
>> >
>> >  IBQuery1.sql.clear;
>> >  IBQuery1.sql.add('select * from stock');
>> >  IBQuery1.open;
>> >  IBQuery1.close;
>> >
>> >  F_MAIN.TRANS.Commit;
>> >
>> >
>> >
>> >"Bill Todd" <bill@notthis.dbginc.com> schrieb im Newsbeitrag
>> >news:pco9vu8ggnpbrg8jq30okset41k765j7nb@4ax.com...
>> >> delete * from stock
>> >> Commit
>> >> StartTransaction
>> >> select * from stock
>> >> insert into stock (id...) values (:id ...)
>> >>
>> >> Doing the SELECT will let IB garbage collect the deleted rows.
>> >>
>> >> On Mon, 4 Nov 2002 18:43:42 +0100, "Dietrich v. Witzleben"
>> >> <info@witzleben-edv.de> wrote:
>> >>
>> >> >delete * from stock
>> >> >insert into stock (id...) values (:id ...)
>> >>
>> >>
>> >> --
>> >> Bill (TeamB)
>> >> (TeamB cannot respond to questions received via email)
>> >
>>
>>
>> --
>> Bill (TeamB)
>> (TeamB cannot respond to questions received via email)
>


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Technical Details
Message-ID: <qsefvuc48c01lq80l7uag4jite35dsgdus@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3df4d656$1@newsgroups.borland.com> <pco9vu8ggnpbrg8jq30okset41k765j7nb@4ax.com> <3df51274@newsgroups.borland.com> <66favuo7kh7r0on6lc1r6hb8qikf6k8qaq@4ax.com> <3df75127$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 114a0e,6aab62eb63eb5ff1
X-Google-Attributes: gid114a0e,public
X-Google-ArrivalTime: 2002-12-11 14:41:07 PST
From: Bill Todd <bill@notthis.dbginc.com>
Newsgroups: borland.public.interbase.sql
Subject: Re: Bulk inserts  makes GDB grow
Date: Wed, 11 Dec 2002 15:27:26 -0700
Message-ID: <qsefvuc48c01lq80l7uag4jite35dsgdus@4ax.com>
References: <3df4d656$1@newsgroups.borland.com> <pco9vu8ggnpbrg8jq30okset41k765j7nb@4ax.com> <3df51274@newsgroups.borland.com> <66favuo7kh7r0on6lc1r6hb8qikf6k8qaq@4ax.com> <3df75127$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.91/32.564
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 216.207.211.30
X-Trace: newsgroups.borland.com 1039645647 216.207.211.30 (11 Dec 2002 14:27:27 -0800)
Lines: 160
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail