Subject Re: [ib-support] Utility to find slow queries?
Author Mark Patterson
Helen Borrie wrote:

> The better the info you supply by way of problem description, the better
> the solution is.

We have 2 threads running, one populating a GUI (TFrame) of saw stations, the
other of Jig Stations. All the fields in the where clauses are indexed. The
primary key is an autoincrement field.

function TfraSawStationJobs.GetJobListSql: string;
begin
result :=
'SELECT DISTINCT JOB_NUMBER FROM SAWMEMBERS'
+ ' WHERE STATUS <= ' + S_COMPLETED
+ ' AND STATION_ID = ' + IntToStr(StationID);
end;// GetJobListSql

procedure TfraSawStationJobs.ReloadTrusses;
begin
if lstJobs.Items.Count > 0 then
begin
if DMConnection.GetImportType(lstJobs.Items[lstJobs.ItemIndex]) = 'BULK' then
begin
lstTrusses.Items.Text := GlobalBulkJob;
end
else
begin
DBUtils.LoadStrings(DMConnection.DbSuite, lstTrusses.Items,
'SELECT DISTINCT TRUSS_NUMBER FROM SAWMEMBERS'
+ ' WHERE STATION_ID = ' + IntToStr(StationID)
+ ' AND JOB_NUMBER = ' + SQLString(JobNumber));
end;
end;
end;// ReloadTrusses
function TfraJigStationJobs.GetJobListSql: string;
begin
result :=
'SELECT DISTINCT JOB_NUMBER FROM JIGTRUSSDETAILS' +
' WHERE STATION_ID = ' + IntToStr(StationID) +
' AND STATUS <= ' + S_COMPLETED;
end;// GetJobListSql

procedure TfraJigStationJobs.ReloadTrusses;
var SQL: string;
begin
SQL := 'SELECT DISTINCT TRUSS_NUMBER FROM JIGTRUSSDETAILS'
+ ' WHERE STATION_ID = ' + IntToStr(StationID)
+ ' AND JOB_NUMBER = ' + SQLString(JobNumber)
+ ' ORDER BY TRUSS_SORT';
DbUtils.LoadStrings(DMConnection.DbSuite, lstTrusses.Items, SQL);
end;// ReloadTrusses


> Not clear what you mean by "the internal structure of the
> tables and indexes".

I'm trying to visualise what the database driver must be doing. I don't know how
the data is laid out on the disk.

Thanks,

Mark