Subject Re: [IBO] Updating a dbGrid/dataset fast
Author Helen Borrie
At 02:23 PM 16/07/2004 -0700, Clive Walden wrote:
>Using TIBOQuery and a DBGrid my users can update a field so that it no
>longer meets the query
>The query itself is slow.

Please show the SQL and the DDL for the table(s) queried.

>Unfortunately, I can not find a quick way to remove the row from the

Simply call Refresh. The data you see in the grid reflects that which is
currently in the dataset buffer. It won't reflect what is in the database
until you refresh the buffer.

>Adding a filter has two problems.
>1. It does not work unless I do a:
>Filtered := False;
>Filtered := True;
>(Not a big deal in itself)

A query with WHERE criteria is already "filtered".

>2. It is very slow (about 3 seconds) so I think it must be re-querying the

Certainly. That's how a filter works. But filtering is a very slow,
do-nothing way to refresh the dataset buffer. It changes the structure of
the query and prompts a complete rebuild of the dataset object. You're
getting all that overhead, on top of an already slow query, to attempt
something that the dataset can already do itself, much more efficiently.

>I tried Dataset.RefreshRowNum(Dataset.RecNo) and that did nothing.

Until you Post and Commit, the changes exist nowhere except in the dataset
buffer. All a Refresh will do is revert the dataset to what it was before.

>Advice would be gratefully received.

The first step is to work out why the query is slow in the first place.

>BTW: This is a major conversion from a Paradox application which is why I
>am (still) using the VCL
>compatible components.

Good thinking. But Firebird/IB are not Paradox. It's quite usual for a
Paradox database that has simply been "converted" without a mind to
relational structure to perform badly. It is an "apples and oranges"
issue, to do with the different ways that Paradox and SQL databases
implement relationships.

But it should behave properly unless there is a structural error.

I've put a drop-dead simple project in the Files area with your name on
STARTING WITH 'J'. (It assumes you have a Firebird installation with
employee.fdb in the standard location. If you don't, change the Path
property to whatever Employee database you have on your system.)

File : /
Uploaded by : helebor <helebor@...>
Description : Refresh demo for Clive Walden

You can access the file at the URL

Compile the project and run it. Choose an initial character to query and
hit the Query button. The IBODatabase is set up with the default
AutoCommit true, which will commit changes when you post them. (There are
issues with this but it'll do for the demo!)

Change the last name on one row, and click the Post button on the
navigator. The AfterPost event will refresh the buffer and you'll see what
you would expect...