Description:
the elapsed time for sqlDescribeCol can be significant (minutes) as it appears that MySQL is executing the query. that can be confirmed by simply adding a conjunct to the predicate testing if 1=0 which results in a fast API call.
sqlPrepare and sqlDescribeCol have to be fast API calls for dynamic SQL applications. executing the query during these calls is not acceptable in general and especially not for queries which are slow etc. further, it means that the application is incurring a 2x cost as it will subsequently execute a sqlExecute for the query.
How to repeat:
create table T1 ( C1 integer, C2 integer )
insert into T1 ( 1, 1) , (2, 1) (3, 1) .... ( 1000000, 1)
create table T2 ( C1 integer, C2 integer)
insert into T2 ( 1, 1) (2, 1), (3, 1) .... ( 10000000, 1)
use ODBCtest or custom program
sqlPrepare select T1.C1, T1.C2, T2.C1, T2.C2 from T1 join T2 on T1.C2=T2.C2
sqlDescribeCol All
while sqlPrepare is fast sqlDescribeCol will be based on how quickly the query executes. Add and 1=0 to the statement and repeat.
Suggested fix: