I am working at the moment with the advantage database server from sybase. I am programming in delphi and I am using a local server. My problem is, if I make a sql query inside my own source code the query is 3 times slower (especially for nested Select queries) as if I would use exactly the same query inside the Advantage Database Architect delivered by sybase, too.
The database is also the same. Is there any optimization step I am missing?
My Source Code looks like this:
//Initializing Connection and Query
FADSConnection.LoginPrompt := false;
FADSConnection.ConnectPath := Filename;
FADSConnection.AdsServerTypes := [stADS_LOCAL];
FADSConnection.Name := 'ADB';
FADSConnection.EncryptionOptions.DataEncryptionType := etAdsAES256;
FADSConnection.IsConnected := true;
FADSQuery.DatabaseName := FADSConnection.Name;
FADSQuery.SourceTableType := ttAdsADT;
FADSQuery.AdsTableOptions.AdsCharType := GERMAN_VFP_CI_AS_437;
s := 'SELECT *'
+ 'FROM ADB_Table1 WHERE No IN'
+'(SELECT No'
+ 'FROM ADB_Table2 WHERE V=0.4 AND N=26 AND No IN'
+ '(SELECT No FROM ADB_Table2 WHERE V=0.6 AND N=8)) AND Count=2'
FADSQuery.sql.Text := s;
FADSQuery.Open;
FADSQuery.first;
The Query takes 600 ms in my program. In the advantage database architect it needs 200 ms. The database has around 18000 entries.
Thank you in advance!
So, I found my mistake:
The Problem is the initialization of the query instance.
Somehow overhanding of the Source Table Type and the AdsCharType isn’t necessary.
I just removed the above lines and my queries are nearly as fast as the Advantage Data Architect.