Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
SRP_Com accessing an indexed datetime MySQL field
First of all, sorry if this has already been covered. If so, I'd appreciate a pointer to it as I didn't find anything covering this scenario.
We are new to ADO and have just figured out that some MySQL datatypes require a 'cast' operation in the query. Unfortunately, one of our queries uses an indexed datetime field in its where clause. Casting this field so ADO will recognize the content will negate its use as an index which severely slows this query down (1,000's of records).
We have not found any solution to this issue besides setting the connection object's 'CommandTimeout' setting to 90-120 seconds. We are wondering if there are any other options out there.
-- thanks
We are new to ADO and have just figured out that some MySQL datatypes require a 'cast' operation in the query. Unfortunately, one of our queries uses an indexed datetime field in its where clause. Casting this field so ADO will recognize the content will negate its use as an index which severely slows this query down (1,000's of records).
We have not found any solution to this issue besides setting the connection object's 'CommandTimeout' setting to 90-120 seconds. We are wondering if there are any other options out there.
-- thanks
Comments
MySQL table
ID field is the primary index - BigInt
ConnectTime field is a datetime field
query "select field1, field2, Cast(ConnectTime as char) as ConnectTime2 where Cast(ConnectTime as date) = '2023-04-22'
if we do not cast the datetime field it will replace the 'date' portion with null.
I used this forum because 1) it's active and 2) I see a lot of informative information here. Just hoping someone else had seen the same issue. I'll try to get some more data and re-post.
sometimes help is just shining a light in a previously-unseen corner :)