In a perl script, I'm reading in data from a mysql server database that has some fields that could be millions of bytes long (DNA sequences). However, I am interested only in the first 1000 or so bases (characters) - and I already know how to use SUBSTRING() to select those.

My question deals more with performance: How does SUBSTRING() actually work? I don't want to read in the whole field, then take a portion of it to get my end...