Hello Michel,
I've reviewed the results. Thanks for taking the time to look at this with me.
> tiny difference provided by the lack (or the presence) of the index
Do you think this is because there was no WHERE clause in the SELECT statements?
> benefit of a better choice of data type for numeric fields
Yes, this makes sense (in my mind anyway). Integer fields only use 4 bytes of storage, whereas Numeric fields use 8 bytes in memory and 1 to 20 bytes in the table.
Since the query is returning all rows, I would expect that it would finish faster if there were less total bytes to be returned. Is this the right way to look at it?
> comparison between MyTable and MyTableIntTTOC
That IS unexpected. From my perspective, the TTOC field should have had a negative impact because of the larger field size in bytes.
However, what I find more amazing is the difference between MyTableIntTTOC and MyTableInt. Going by the "it takes more time to return more bytes" theory, this result should not be.
I did the same tests between N(X,x), Int and TTOC and came up with result similar to yours:
MyTable - 75 seconds
MyTableInt - 50 seconds
MyTableIntTTOC - 41 seconds
So perhaps the VFP DateTime data type is not as efficient to retrieve via OLE DB, and/or takes more time to convert into an equivalent SQL Server datatype..?
And while the results are interesting, I am not sure how this directly applies to my original issue...
Did you get similar results as I when querying with a WHERE on the he_tDtHearing field?
In my scenario, I will be using a WHERE clause in each query. For Integer and Numeric fields, the indexes are used and the results are returned as fast as I would expect. But, for DateTime fields, I cannot find a way to optimize the WHERE clause so that an index is used.
If I were able to figure this out, I would be able to set up a view in SQL Server on the linked VFP table, then run queries on it with normal SQL syntax with parameters. Without this, I'm forced to use OPENQUERY - which works, but will be more effort to assemble each query.
Thanks.