I am wondering what the best (read: fastest) way is to find the entry in the result set of the TQUery SQL statement.
So far, I am using TQuery.Locate, and if I'm right, this is the only statement that can be used to search in a result set. So how can we optimize this?
I have several ideas, but have not yet managed to compare them all on large data sets:
Let's say we have a table with the following fields:
Create Table aTable ( ID int, Name1 varchar(50), Name2 varchar(50));
And the following query:
SELECT ID, Name1, Name2 from aTable
We want to find the record by its identifier in the result set
- Will the search be faster if aTable has an index in ID?
- Will the search be faster if I add "Order By ID" to the SQL statement?
Any ideas on this?
[Edit] To explain how to use it: the query is executed using the Dataview Reportbuilder, and then is accessible through the datapipeline (this is TQuery.Dataset). In a custom report, I need to go down the pipeline based on a higher level identifier. Therefore, DO NOT use the query here is not applicable. I'm just wondering if any of my suggestions will speed up above.
Bascy source share