Skip to main content
Participant
July 14, 2007
Question

Slow mySQL select - mySQL/JDBC/CFMX issue?

  • July 14, 2007
  • 3 replies
  • 751 views
Hello!

I have got two simple SQL statements in my CFMX app:

SELECT
companyname,
uidnumber,
description,
telephone
FROM
companies
WHERE
entrykey = ?
;

Query Parameter Value(s) -
Parameter #1(cf_sql_varchar) = 2405961E-FE08-E3BE-059C648DC01198A9

SELECT
LEFT(companyname, 250) AS companyname,
LEFT(uidnumber, 100) AS uidnumber,
LEFT(description, 250) AS description,
LEFT(telephone, 100) AS telephone
FROM
companies
WHERE
entrykey = ?
;

Query Parameter Value(s) -
Parameter #1(cf_sql_varchar) = 2405961E-FE08-E3BE-059C648DC01198A9

Both return the same result, but the second one only take 1 msec, the first one 30 msec. The number of chars to return (using LEFT) is exactly the length of the field (no data is shortend). What could be the reason for that difference? Any methods to make query #1 as fast as query #2?

system: JDBC 5.0 / myISAM tables with UTF-8 encoding / CFMX7 app server

best regards,

Hansjoerg
This topic has been closed for replies.

3 replies

Participating Frequently
July 15, 2007
And if entrykey is not identified as a primary key you might try creating an index on it to speed things up.
Inspiring
July 15, 2007
What happens if you run them in the opposite order? As BKBK said, one of the reasons the first one was slower may have been connection time.
BKBK
Community Expert
Community Expert
July 15, 2007
It could be that the second query made use of the connection that the first established. In fact, if MySQL sees the second query as identical to the first it will not run the second query. It will simply return the first result-set from cache.



Participant
July 15, 2007
Hello!

- Index exists, table is optimized (and currently has just 5 records).
- I tried to change the order, no change. The version with the simple naming of the desired fields is always up to 10-100 times slower than the version with LEFT( ...).
- I now went back to mysql-connector-java-3.0.17-ga-bin.jar from version mysql-connector-java-5.0.6 - now both queries have the same speed (about 1-3 msec).

So it seems to be a JDBC driver issue but I cannot find any information on the net why the newer version is sooo much slower.

Best regards,

Hansjoerg
Inspiring
July 17, 2007
I have experienced similar performance issues with connector 5.0.6. Did you try connector 3.1.14?