Board index » delphi » Why does Interbase retrieve all records?

Why does Interbase retrieve all records?

I have the following set-up:

Delphi 2.0, Local Interbase 4.1, 64MB RAM
A Datamodule with a TDatabase, TDataSource, and TQuery

In a separate form I have a TDBGrid where I want the following query
displayed:

select SITE_CODE, SITE_NAME, SITE_CITY, SITE_STATE, SITE_STATE
from SITE;

and the BDE seems to read every record (10,000 of them) from the database into
memory.  If I scroll through the list I never get an SQL hourglass.  I don't
want all the records using memory because it takes too long whenever I refresh
the grid.  It doesn't do this for all my queries, and the above grid works as
expected while in the Delphi IDE (I get an SQL hourglass during scroll). Any
ideas what is happening?  

BTW RequestLive is set to False in the TQuery.

- Kai

 

Re:Why does Interbase retrieve all records?


Quote
lauri...@digitalcourier.com (Kai Laurinolli) wrote:
> I have the following set-up:

> Delphi 2.0, Local Interbase 4.1, 64MB RAM
> A Datamodule with a TDatabase, TDataSource, and TQuery

> In a separate form I have a TDBGrid where I want the following query
> displayed:

> select SITE_CODE, SITE_NAME, SITE_CITY, SITE_STATE, SITE_STATE
> from SITE;

> and the BDE seems to read every record (10,000 of them) from the database into

Seems normal to me that Interbase returns all records, since you don't
limit your query to something specific.

Quote
> memory.  If I scroll through the list I never get an SQL hourglass.  I don't

Meaning it's either hyper-fast, more probably that it's already there
(i.e. because the TQuery is set active and the datamodule is loaded
first).

Jasper

Re:Why does Interbase retrieve all records?


Quote
In article <33194e4c.5733...@news.euronet.nl>, dirks...@euronet.nl (Jasper Stil) wrote:
>lauri...@digitalcourier.com (Kai Laurinolli) wrote:

>> I have the following set-up:

>> Delphi 2.0, Local Interbase 4.1, 64MB RAM
>> A Datamodule with a TDatabase, TDataSource, and TQuery

>> In a separate form I have a TDBGrid where I want the following query
>> displayed:

>> select SITE_CODE, SITE_NAME, SITE_CITY, SITE_STATE, SITE_STATE
>> from SITE;

>> and the BDE seems to read every record (10,000 of them) from the database
> into

>Seems normal to me that Interbase returns all records, since you don't
>limit your query to something specific.

>> memory.  If I scroll through the list I never get an SQL hourglass.  I don't

>Meaning it's either hyper-fast, more probably that it's already there
>(i.e. because the TQuery is set active and the datamodule is loaded
>first).

>Jasper

I figured it out finally.  It appears that you must mke sure that the TQuery
is inactive before starting the transaction.  Don't ask me why but if I do the
following it works fine:

MainDataModule.SiteQuery.Active := False;
MainDataModule.Database.StartTransaction;
MainDataModule.SiteQuery.Active := True;

- Kai

Other Threads