Article View: borland.public.interbase.sql
Article #11210Re: Bulk inserts makes GDB grow
From: Dietrich v. Witzleben
Date: Wed, 11 Dec 2002 14:52
Date: Wed, 11 Dec 2002 14:52
148 lines
4959 bytes
4959 bytes
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)
Technical Details
Message-ID:
<3df75127$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3df4d656$1@newsgroups.borland.com> <pco9vu8ggnpbrg8jq30okset41k765j7nb@4ax.com> <3df51274@newsgroups.borland.com> <66favuo7kh7r0on6lc1r6hb8qikf6k8qaq@4ax.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 06:56:22 PST Reply-To: "Dietrich v. Witzleben" <info@witzleben-edv.de> From: "Dietrich v. Witzleben" <info@witzleben-edv.de> Newsgroups: borland.public.interbase.sql References: <3df4d656$1@newsgroups.borland.com> <pco9vu8ggnpbrg8jq30okset41k765j7nb@4ax.com> <3df51274@newsgroups.borland.com> <66favuo7kh7r0on6lc1r6hb8qikf6k8qaq@4ax.com> Subject: Re: Bulk inserts makes GDB grow Date: Wed, 11 Dec 2002 15:52:12 +0100 Lines: 150 Organization: WITZLEBEN EDV X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 217.82.11.60 Message-ID: <3df75127$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1039618343 217.82.11.60 (11 Dec 2002 06:52:23 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail