Optimiser un ClientDataSet
Bonjour, je recherche comment je pourrais optimiser le bout de code suivant. Pour vous mettre dans le contexte, j'ai une application qui, par le biais d'un SDK, donne accès à sa base de donnée. Je développe une applications tiers qui lit dans cette base de donnée et qui met les informations dans un DBGrid. Par contre, avec environ 10 000 records, cette opération prend environ 10 secondes ce qui est beaucoup trop long. Y'a-t-il moyen d'accélérer cette opération?
Merci beaucoup pour votre aide!
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| procedure TForm5.LoadProductList;
var
//Déclaration de l'interface
ProductData : Product;
//Déclaration des variables
Error : Longint;
Compteur : Longint;
i : Longint;
Acomba : AcombaX;
begin
Acomba := CoAcombaX.Create;
//Initialisation de CustomerData
ProductData := CoProduct.Create;
//Déterminer le nombre total de fiches de client
Error := Acomba.NumCards(ProductData, Compteur);
ClientDataSet1.DisableControls;
if Error = 0 then
begin
//Consulter les fiches une à une dans le fichier des clients
for i := 1 to Compteur do
begin
Error := Acomba.GetCard(ProductData, i);
if Error = 0 then
begin
//Affichage des clients actifs seulement
if ProductData.PrActive <> 0 then
begin
ClientDataSet1.InsertRecord([ProductData.PrNumber, ProductData.PrDescription[1], ProductData.PrProductGroupNumber, ProductData.PrSortKey[1], ProductData.PrSortKey[2], '', '', '', ProductData.PrQtyOnHand, ProductData.PrQtyOrdered, ProductData.PrQtyPurchasing, ProductData.PrUnique]);
end;
end
else
ShowMessage('Erreur: ' + Acomba.GetErrorMessage(Error));
end;
end
else
ShowMessage('Erreur: ' + Acomba.GetErrorMessage(Error));
ClientDataSet1.EnableControls;
DBGrid1.DataSource.DataSet.First();
end; |