Subject Re: [ib-support] Delphi TIBQuery.Locate
Author Martijn Tonies
Hi Julien,

> I've got a table Article and an index on the field CODE_BARRES of
> this table
> when I do
> QArticle.Locate('CODE_BARRES', ECodeBare.Text, []);

Ah great ... and what makes you think the index is used?

With a flat-file/local file database thingy, the "indices" are kept
in memory. Then, when you use a .Locate method, it scans the
index and pulls the records you want from the file.

With a client/server database, the SERVER uses the indices.
And the client "asks" (queries) for a certain resultset - you never
work with a "table" directly, always with a result to a query...

Now, by using TIBQuery and the .Locate method, the only thing
you're doing is pulling all records across the line that you asked
for - (depending on the .SQL property) - then, in the local buffer
you're doing a .Locate and you're searching for the record...

To work with C/S database engines, keep your resultset as small
as possible - so instead of asking for 3000 records - only ask for
a couple that already match certain criteria - like 'Starts with an A'

> the answer is very long (nearly one minute, and there's only 3000
> records in the table);
> With an Microsoft Access database everything works fine. And in the

Of course it does - because it is a flat file system...

Hope this helps,

Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird

Upscene Productions

"This is an object-oriented system.
If we change anything, the users object."