Subject Re: [IBO] Search Data without refetching
Author Helen Borrie
At 09:52 AM 30/04/2006, you wrote:
>I'm using an IB Cursor to retrieve a list of dates and times. Now I
>need a very fast way to check the data (at most 200 hundred records)
>to see if a particular date and time is in it.

Then an IB_Cursor is the wrong choice, since it is unbuffered.

>I could use a parameterized query to check for individual
>times(instead of getting the whole list), but this is too slow as the
>operation needs to run up to a few hundred times in a span that's
>imperceptible to the user.

I don't understand this. A parameterised query should be the fastest
way to get this answer. Depending on what you want to do (just get
the answer, or get rows if they exist, otherwise IsEmpty) you could
use an existence query for maximum speed.

>How can I search the data without having to go to the server to
>refetch the results? Will using "locate" cause the data to be requeried?

With an IB_Cursor, you would have to store the results somewhere,
e.g. in a pair of stringlists. But that approach is not
efficient. It requires fetching the set first and afterwards
checking to see whether it has the data you want. That is desktop
database stuff. Locate doesn't work on an unbuffered dataset (and
it's inefficient on a buffered one).

With an IB_Query, you get a buffered dataset with a "moving
window". Locate will search the set and fetch more rows if it needs to.

IMO, you need to rethink what you want to achieve. If you are
interested only in rows that meet the date specification then target
only those rows, by parameterising the WHERE clause. Pulling a
dataset across and THEN testing it is very inefficient for this kind
of operation.


>IB Objects - direct, complete, custom connectivity to Firebird or InterBase
> without the need for BDE, ODBC or any other layer.
> - your IBO community resource for Tech Info papers,
>keyword-searchable FAQ, community code contributions and more !
>Yahoo! Groups Links