Search by primary key performance
Posted: Tue 07 Feb 2017 14:40
Hi,
I need to perform many searches by primary key field of table:
Table contains about 7 millions records. I need to check some huge CSV file against this table to detect is some IDs already exists in them:
I try to search like this:
But I can reach max 1200 searches per second (on Core i7 3.3 ghz and SSD drive) ! I thinks it's terrible slow. Maybe I miss some LiteDAC settings ? What settings is optimal for above task ?
I need to perform many searches by primary key field of table:
Code: Select all
CREATE TABLE List1 (
ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
Name VARCHAR
);
I try to search like this:
Code: Select all
var
NewIDsFound:Integer;
begin
LocalQuery.SQL.Add('SELECT Name FROM List1 WHERE ID=:myid');
LocalQuery.Prepare;
LocalQuery.DisableControls;
NewIDsFound:=0;
for i := 0 to InList.Count-1 do
begin
LocalQuery.Params[0].AsInteger:=InList.IntValue[i];
LocalQuery.ExecSQL;
if LocalQuery.eof then
Inc(NewIDsFound);
end;
LocalQuery.Unprepare;
end;