# Slow String field Select - what's responsible?

**URL:** <https://forums.percona.com/t/slow-string-field-select-whats-responsible/385>\
**Category:** Other MySQL® Questions\
**Created:** [July 13, 2007, 2:42pm UTC](https://forums.percona.com/t/slow-string-field-select-whats-responsible/385 "2007-07-13T14:42:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![funkymusic](https://avatars.discourse-cdn.com/v4/letter/f/4491bb/32.png) [@funkymusic](https://forums.percona.com/u/funkymusic)\
**Post date:** [July 13, 2007, 2:42pm UTC](https://forums.percona.com/t/slow-string-field-select-whats-responsible/385/1 "2007-07-13T14:42:35Z")

</div>

Hello!

I have got two simple SQL statements:

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,

Peter

---

<div class="post-metadata">

**Author:** ![barryhunter](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@barryhunter](https://forums.percona.com/u/barryhunter)\
**Post date:** [July 17, 2007, 7:19am UTC](https://forums.percona.com/t/slow-string-field-select-whats-responsible/385/2 "2007-07-17T07:19:56Z")

</div>

What indexes do you have on the tables?

I wonder if by explicitly stating the length of the string, the optimizier can be sure it can get that data from the index, and doesnt need to goto toe actual data. Without the length it doesnt know that for sure and has to check anyway.

If you can I guess the Explain output for the two queries would be helpful.
