I have a million records in one of my database table which my FDQuery is pointed to. Here's my SQL query:
SELECT DISTINCT variant FROM item_var
JOIN item ON item_var.item_id = item.list_id
WHERE item.brand = :itemselected
ORDER BY variant //I did not put a limit because the data here very limited say maximum 10 only
The parameter ":itemselected" is to be triggered by my TListView1 selected item.
The result of this query is populate to be populated to my TListView2 with this code:
if dmMain_u.dmMain.qryVariant.RecordCount >= 0 then
begin
with dmMain_u.dmMain do
begin
qryVariant.Active := False;
qryVariant.Params.ParamByName('itemselected').AsString := lsvItems.Items[lsvItems.ItemIndex].Text;
qryVariant.Active := True;
end;
end;
I am using livebindings for both TListViews and my database is SQLite embedded local.
The above codes seems to taking a while to populate the data to my TListView2 (like 5 seconds). I am hoping that you guys have better options to share. Perhaps, my codes are not efficient or optimize enough.