Article View: borland.public.cppbuilder.database.ado
Article #1268Re: Adoquery slow record retreval
From: Viatcheslav V. Vassiliev
Date: Tue, 07 Sep 2004 17:44
Date: Tue, 07 Sep 2004 17:44
107 lines
5215 bytes
5215 bytes
Please look example in $(OLEDBDirect)\Examples\FetchIntoObjects (OLEDB
Direct should be installed, trial is available on
http://www.oledbdirect.com). It shows how to fetch data into TObject
descendant. The code is the same for other class or struct. Data types that
you bind to db fields should have OLEDB compatible data type - for example,
you can not use AnsiString but could use WideString or array of char (or
widechar). Binding directly to record is more difficult and requires more
coding but it is faster than ADO.
If you need example for your case, please write table structure in form of
SQL CREATE TABLE and definition of your record (possibly it need to be
changed - change AnsiStrings to array of char or WideStrings).
The same could be used for inserts too - look, for example,
CreateAndFillJetTable example.
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"William" <wwestbrooks@houston.rr.com> �������/�������� � ��������
���������: news:413dc7bd$1@newsgroups.borland.com...
> Can you give me a code example of how to Directly fetch records directly
> into CustLocaTableRec record, without convertion of db value into Variant
> and back to record field type.
>
>
> "Viatcheslav V. Vassiliev" <support@oledbdirect.com> wrote in message
> news:41396b4f@newsgroups.borland.com...
> > 1. Use server-side cursor (CursorLocation = crUseServer).
> > 2. Do not use FindFirst(), use First().
> > 3. Do not use RecordCount - use:
> >
> > while (!ADOQuery1->Eof)
> > {
> > ...
> > ADOQuery1->Next();
> > }
> >
> > 4. Call DisableControls()/EnableControls() even if there are no controls
> > attached.
> >
> > BTW, with OLEDB Direct you will be able to fetch records directly into
> > CustLocaTableRec record, without convertion of db value into Variant and
> > back to record field type.
> >
> > //------------------------------------------
> > Regards,
> > Vassiliev V. V.
> > http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
> > ADO.Net
> > http://www.oledbdirect.com - The fastest way to access MS SQL Server,
> > MS Jet (Access) and Interbase (through OLEDB)
> >
> > "William" <wwestbrooks@houston.rr.com> �������/�������� � ��������
> > ���������: news:4138c989$1@newsgroups.borland.com...
> > > Hi
> > >
> > > I am using a TADOQuery component to access a local MS Access
> database
> > > table on my machine. The problem is the time it takes to read all the
> > > records in the table is unacceptably slow. I have about 160,000
records
> in
> > > the table and I read in each records information. If I comment out all
> the
> > > code in my loop and only leave the statement ADOQuery1->Next(), this
is
> > the
> > > bottle neck it takes about five minutes to retrieve all the records. I
> > tried
> > > setting the CacheSize property to 10,000 but it didn't speed up the
> > > application. How can I optimize accessing the data, to make it
> expectable.
> > > My code is below.
> > >
> > > // Go to the first record
> > > ADOQuery1->FindFirst();
> > > for(i1=0;i1<ADOQuery1->RecordCount;++i1) {
> > > // Catch conversion errors
> > > try {
> > > CustLocTableRec.X = ADOQuery1->FieldValues["X"];
> > > CustLocTableRec.Y = ADOQuery1->FieldValues["Y"];
> > > CustLocTableRec.NodeID =
> ADOQuery1->FieldValues["NodeID"];
> > > CustLocTableRec.LegID =
ADOQuery1->FieldValues["LegID"];
> > > } catch(...) {
> > > LOGWARNINGS = true;
> > > break;
> > > }
> > > CustLocTableRec.Used = false;
> > > CustLocTable[ADOQuery1->FieldValues["ServiceID"]] =
> > > CustLocTableRec;
> > > ADOQuery1->Next(); // Bottle neck
> > > }
> > >
> > >
> >
> >
>
>
Technical Details
Message-ID:
<413df391@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4138c989$1@newsgroups.borland.com> <41396b4f@newsgroups.borland.com> <413dc7bd$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,7660a242b4ab7f8a X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <4138c989$1@newsgroups.borland.com> <41396b4f@newsgroups.borland.com> <413dc7bd$1@newsgroups.borland.com> Subject: Re: Adoquery slow record retreval Date: Tue, 7 Sep 2004 21:44:49 +0400 Lines: 109 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 213.234.218.42 Message-ID: <413df391@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1094579089 213.234.218.42 (7 Sep 2004 10:44:49 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail