Board index » delphi » TQuery, CachedUpdates, Filter and RecordCount bug

TQuery, CachedUpdates, Filter and RecordCount bug

Hi:

I am using D5 and try to use TQuery, CachedUpdates and Filter to handle
master detail data.(Don't ask me why use filter to handle master/detail
data, as I have 3 layers master/detail and delphi can not handle this if use
CachedUpdates.)  Data filtered displayed properly in dbgrid while the
recordcount shows the whole dataset's records. I think this is a Delphi bug.

Can anyone tell me how to solve this problem? Thanks.

Roland

 

Re:TQuery, CachedUpdates, Filter and RecordCount bug


Quote
Roland wrote:
> Hi:

> I am using D5 and try to use TQuery, CachedUpdates and Filter to
> handle master detail data.(Don't ask me why use filter to handle
> master/detail data, as I have 3 layers master/detail and delphi can
> not handle this if use CachedUpdates.)  Data filtered displayed
> properly in dbgrid while the recordcount shows the whole dataset's
> records. I think this is a Delphi bug.

> Can anyone tell me how to solve this problem? Thanks.

> Roland

This is not a bug. To show the correct record count for a filtered
dataset Delphi would have to read the entire table and count the
records that match the filter criteria. This would cause very poor
performance on large tables.

Why do you need the record count?

What database are you using?

--
Bill Todd (TeamB)

Re:TQuery, CachedUpdates, Filter and RecordCount bug


Thanks Bill:

I have master detail layers like this: master/detail/detail

master table primary key: auto generated
first detail table primary key: master primary key, line no
second detail table priary key: master primary key, first detail's line no,
line no

All these tables data I use query to get them.

Due to catchedupdates problem, I have to query second detail by master
primary key, and then use filter to synchronize with first detail dataset.

When insert new record, I count the total records and then plus 1 to assign
to line no, and that causes problem.

If I set catchedupdates = false for second detail dataset, it shows correct
recordcount after filtering.

My question is why dbgrid can display data correctly but the recordcount is
wrong? Any way to get correct record count?

Thanks

Roland

Quote
"Bill Todd" <n...@no.com> wrote in message

news:43d6e19c$1@newsgroups.borland.com...
Quote
> Roland wrote:

>> Hi:

>> I am using D5 and try to use TQuery, CachedUpdates and Filter to
>> handle master detail data.(Don't ask me why use filter to handle
>> master/detail data, as I have 3 layers master/detail and delphi can
>> not handle this if use CachedUpdates.)  Data filtered displayed
>> properly in dbgrid while the recordcount shows the whole dataset's
>> records. I think this is a Delphi bug.

>> Can anyone tell me how to solve this problem? Thanks.

>> Roland

> This is not a bug. To show the correct record count for a filtered
> dataset Delphi would have to read the entire table and count the
> records that match the filter criteria. This would cause very poor
> performance on large tables.

> Why do you need the record count?

> What database are you using?

> --
> Bill Todd (TeamB)

Re:TQuery, CachedUpdates, Filter and RecordCount bug


I am using interbase, and the data queried out only contains one master
record, several first detail's records and several second detail's records,
that should not affect performance as I am similating thin client idea
though my application structure is not 3 tier.

Roland

Quote
"Bill Todd" <n...@no.com> wrote in message

news:43d6e19c$1@newsgroups.borland.com...
Quote
> Roland wrote:

>> Hi:

>> I am using D5 and try to use TQuery, CachedUpdates and Filter to
>> handle master detail data.(Don't ask me why use filter to handle
>> master/detail data, as I have 3 layers master/detail and delphi can
>> not handle this if use CachedUpdates.)  Data filtered displayed
>> properly in dbgrid while the recordcount shows the whole dataset's
>> records. I think this is a Delphi bug.

>> Can anyone tell me how to solve this problem? Thanks.

>> Roland

> This is not a bug. To show the correct record count for a filtered
> dataset Delphi would have to read the entire table and count the
> records that match the filter criteria. This would cause very poor
> performance on large tables.

> Why do you need the record count?

> What database are you using?

> --
> Bill Todd (TeamB)

Re:TQuery, CachedUpdates, Filter and RecordCount bug


Borland stopped developing and maintaining the BDE years ago. The last
version of InterBase that is fully supported by the BDE is InterBase
5.6. I strongly recommend that you not use the BDE. The best component
set for working with InterBase in a Win32 app is InterBase Express. The
other choice is dbExpress.

You should never use filters with a SQL database server. A filter is
done on the client and requires all the records to be read across the
network to the client. This does not perform well and it does not scale.

I do not understand why you want to use cached updates when InterBase
fully supports transactions. Cached updates has several serious
problems which is why Borland abandoned them. If you need to buffer
changes on the client use TClientDataSet, not cached updates.

You can easily implement a one-to-many-to-many relationship using query
components linked via their DataSource properties.

--
Bill Todd (TeamB)

Re:TQuery, CachedUpdates, Filter and RecordCount bug


First of all, let's talk about the title, is this a bug? If not can you
explain to me why dbgrid shows correct records while recordcount is wrong?

The program I am maintaining is the BDE based big program. It has
master/detail linking by datasource, but we need improve it by implementing
thin client idea. Currently the program using transaction, but there is one
drawback that we are using DBAware components, so from starttransaction to
commit may take hours if operator leaving the computer.

As it's a big program we are maintaining, it will be very costy if shift all
components to ibexpress or using  TClientDataset. By the way, TClientDataset
also have a big drawbacks on itself, etc speed, we have used TClientDataset
in 3tier application, the speed is annoying together with some unknown bugs.

As I said, I only download ONE MASTER RECORD AND SERVERAL DETAIL RECORDS
from db server and this is not the issue of speed using filter in
Cachedupdates, if not using cachedupdates, I will not use filter. By using
TQuery to download one record is much faster then if I use TClientdataset to
query one record.

Anyhow, I can use dataset.last to get the maximum line no as an altinative
way, but this is just a bit ugly I feel.

Roland

Quote
"Bill Todd" <n...@no.com> wrote in message

news:43d78ddd$1@newsgroups.borland.com...
Quote
> Borland stopped developing and maintaining the BDE years ago. The last
> version of InterBase that is fully supported by the BDE is InterBase
> 5.6. I strongly recommend that you not use the BDE. The best component
> set for working with InterBase in a Win32 app is InterBase Express. The
> other choice is dbExpress.

> You should never use filters with a SQL database server. A filter is
> done on the client and requires all the records to be read across the
> network to the client. This does not perform well and it does not scale.

> I do not understand why you want to use cached updates when InterBase
> fully supports transactions. Cached updates has several serious
> problems which is why Borland abandoned them. If you need to buffer
> changes on the client use TClientDataSet, not cached updates.

> You can easily implement a one-to-many-to-many relationship using query
> components linked via their DataSource properties.

> --
> Bill Todd (TeamB)

Re:TQuery, CachedUpdates, Filter and RecordCount bug


Quote
Roland wrote:
> First of all, let's talk about the title, is this a bug? If not can
> you explain to me why dbgrid shows correct records while recordcount
> is wrong?

No, this behavior is a WAD. To get the recordcount the filter would
have to scan the entire dataset and count the records that pass the
filter criteria. This would be very slow with a large dataset.

--
Bill Todd (TeamB)

Re:TQuery, CachedUpdates, Filter and RecordCount bug


If Cachedupdates = true, does it still scan physical table too?

Roland

Quote
"Bill Todd" <n...@no.com> wrote in message

news:43d841bf$1@newsgroups.borland.com...
Quote
> Roland wrote:

> > First of all, let's talk about the title, is this a bug? If not can
> > you explain to me why dbgrid shows correct records while recordcount
> > is wrong?

> No, this behavior is a WAD. To get the recordcount the filter would
> have to scan the entire dataset and count the records that pass the
> filter criteria. This would be very slow with a large dataset.

> --
> Bill Todd (TeamB)

Re:TQuery, CachedUpdates, Filter and RecordCount bug


Quote
Roland wrote:
> If Cachedupdates = true, does it still scan physical table too?

AFAIK, yes since the cache only contains the changes.

--
Bill Todd (TeamB)

Re:TQuery, CachedUpdates, Filter and RecordCount bug


Quote
> Roland wrote:

>> If Cachedupdates = true, does it still scan physical table too?

> AFAIK, yes since the cache only contains the changes.

> --
> Bill Todd (TeamB)

I don't think when filtering data, it scan physical db. You can have a test.
Query out data from db, shutdown the interbase server, do filtering, no
problem. So filtering definitely not scan physical db if you use query
unless you use TTable.

So no doubt, this is a bug, but foturnately we can work around it out.

Roland

Re:TQuery, CachedUpdates, Filter and RecordCount bug


Cached updates has numerous problems which is why Borland has
recommending using TClientDataSet instead of cached updates since D3.

--
Bill Todd (TeamB)

Re:TQuery, CachedUpdates, Filter and RecordCount bug


Thanks anyway.

Roland

Quote
"Bill Todd" <n...@no.com> wrote in message

news:43dd7614$1@newsgroups.borland.com...
Quote

> Cached updates has numerous problems which is why Borland has
> recommending using TClientDataSet instead of cached updates since D3.

> --
> Bill Todd (TeamB)

Other Threads