Locate extremely slow on ZeosLib components
Posted: 19.05.2009, 13:57
Hello,
I just stopped by to publish a few results I obtained while comparing the ZeosLib components against regular BDE components. More specifically locating records by key with TTable versus TZTable. Both using the "Locate" function.
I was wondering if something can be done regarding the very poor performance of the Locate command of the TZTable.
I made this comparisons because I just recently converted a legacy Paradox system to MySQL without changing much of the code (compatibility and time constraints), almost a simple component replacement (from BDE to ZeosLib).
When all was ready I noticed that the system was several times slower than before. After analyzing the code I noticed that it used Locate all the time. It was then that I decided to run a comparison between TTable.Locate and TZTable.Locate. Here are the results, please feel free to ask me whatever you want about the environment in which this test was run:
[Results.zip file Locate-CaseInsensitive.bmp]
- Using Locate with [loCaseInsensitive] in both TTable and TZTable.
[Results.zip file Locate-NoOptions.bmp]
- Using Locate with no options [] in both TTable and TZTable.
*** As a base test comparison I used the ZQuery component with the optimal query for the same "Locate".
*** i.e: Locate("Field1", [Value1], []) to "SELECT * FROM TABLENAME WHERE Field1=Value1".
Test environment
Machine: Intel Pentium IV 1.6Ghz 512Mb RAM
MySQL: Server Version 5.1 running as a service
Paradox: BDE Version 5.2.2
Table: Its a table with 39,209 records in it. The same data and structure are replicated in Paradox and MySQL. The key fields are strings. I might be able to send you the databases upon request (company property..).
Code snippet:
ZQuery Test
TZable Test
TTable Test
If anyone can give me an idea of how to improve this I'll gladly try and do it myself and post back for the community. But I'm in a short time constraint here and any help would be much appreciated.
I just stopped by to publish a few results I obtained while comparing the ZeosLib components against regular BDE components. More specifically locating records by key with TTable versus TZTable. Both using the "Locate" function.
I was wondering if something can be done regarding the very poor performance of the Locate command of the TZTable.
I made this comparisons because I just recently converted a legacy Paradox system to MySQL without changing much of the code (compatibility and time constraints), almost a simple component replacement (from BDE to ZeosLib).
When all was ready I noticed that the system was several times slower than before. After analyzing the code I noticed that it used Locate all the time. It was then that I decided to run a comparison between TTable.Locate and TZTable.Locate. Here are the results, please feel free to ask me whatever you want about the environment in which this test was run:
[Results.zip file Locate-CaseInsensitive.bmp]
- Using Locate with [loCaseInsensitive] in both TTable and TZTable.
[Results.zip file Locate-NoOptions.bmp]
- Using Locate with no options [] in both TTable and TZTable.
*** As a base test comparison I used the ZQuery component with the optimal query for the same "Locate".
*** i.e: Locate("Field1", [Value1], []) to "SELECT * FROM TABLENAME WHERE Field1=Value1".
Test environment
Machine: Intel Pentium IV 1.6Ghz 512Mb RAM
MySQL: Server Version 5.1 running as a service
Paradox: BDE Version 5.2.2
Table: Its a table with 39,209 records in it. The same data and structure are replicated in Paradox and MySQL. The key fields are strings. I might be able to send you the databases upon request (company property..).
Code snippet:
ZQuery Test
Code: Select all
const
SQL_TXT = 'SELECT * FROM %s WHERE OPERANDO="%s" AND CLAVE="%s"';
begin
ZConnection1.Disconnect;
ZConnection1.Database := ADatabase;
ZConnection1.Connect;
while ARepeticion > 0 do
begin
ZQuery1.Close;
ZQuery1.SQL.Clear;
ZQuery1.SQL.Add(Format(SQL_TXT, [ATable, Edit4.Text, Edit5.Text]));
ZQuery1.Open;
ZQuery1.First;
Dec(ARepeticion);
end;
end;
Code: Select all
begin
ZConnection1.Disconnect;
ZConnection1.Database := ADatabase;
ZConnection1.Connect;
ZTable1.Close;
ZTable1.TableName := ATable;
ZTable1.Open;
while ARepeticion > 0 do
begin
ZTable1.First;
ZTable1.Locate('Field1;Field2', VarArrayOf([Edit4.Text, Edit5.Text]), [{loCaseInsensitive}]);
Dec(ARepeticion);
end;
end;
Code: Select all
begin
Table1.Close;
Table1.DatabaseName := ADatabase;
Table1.TableName := ATable;
Table1.Open;
while ARepeticion > 0 do
begin
Table1.First;
Table1.Locate('Operando;Clave', VarArrayOf([Edit4.Text, Edit5.Text]), [{loCaseInsensitive}]);
Dec(ARepeticion);
end;
end;