I have a large MySQL photos table, and even with full-text indexing, normal indexing, and other performance tricks, I’m finding my query is getting a little slower (crappy MySQL full-text).
I have two fields, one called ‘caption’ and the other ‘shortCaption’. The ‘caption’ field contains 500,000 rows of data between 150 and 2000 characters in length and the new ‘shortCaption’ field is empty.
The searchable information within my ‘caption’ field is mostly in the first 300 characters, so to speed up my full-text query I would like to have a ‘shortCaption’ field that contains the first 300 characters only, making less work for my DB/query.
Is there a way, in one query, to iterate through each photo record, grabbing the first 300 characters (length(field,300)) and updating the new field with the shorter version? I was just about to write a little server-side script that dealt with this, but curious to see if it can be done purely with SQL as it would be quicker.
Thanks in advance.
This query would update all the rows in
tablename