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 result, because reading in the rest of the field is just wasted time/effort. And when I only want 1000 bases out of millions, that's a lot of wasted time. Since locally I don't have the string already saved, does the mysql SUBSTRING command (within a larger SELECT statement) get all of the field, or does it find the beginning and just read up to what I've specified.
Any suggestions for other ways around this problem?
I'm running an openSUSE Linux distribution, if that's relevant at all.
Thanks