Locate very slow when table record > 1000,000 rec

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 12
Joined: Tue 16 May 2006 06:55
Location: Iran-Tehran

Locate very slow when table record > 1000,000 rec

Post by b_yaghobi » Sat 05 Apr 2008 19:57

Hi CoreLab team

suppose you have a table with >= 1000,000

when you want to locate a record that accidental in a last last record in

your table, Locate very very slow to find this record !!!!

Example :

T1 : (Filed1, Field2, ...) (Field1 is PK)

Table Values :

Now :

T1.Locate('Field1', 1000,000, []) -> Very Very Slow

( Please dont tell me to use Query for found this record ! )

Thanks for your Advice and your the best of the best Packages

Posts: 3
Joined: Sun 06 Apr 2008 18:42
Location: Montréal

Locate Field1

Post by Trianon » Sun 06 Apr 2008 19:24

Did you specified Field1 in the IndexFieldNames property of your Dataset?

Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 07 Apr 2008 10:31

Trianon is right. Specifying Field1 in IndexFieldNames will improve performance of locate operations. This happens because SDAC builds index by fields specified in IndexFieldNames and performs the binary search using this index.

Also when you open a dataset in FetchAll=False mode, the first call to Locate will be slow because it forces fetch for all records.

Post Reply