On 2018-01-24 15:21, Ted Roche wrote:
First off, don't do that. REPLACE (or better, UPDATE) once. Especially in high network traffic situations, the amount of time it takes to assemble a field and value list to issue one:
UPDATE TableName SET &lcSetFieldsToValues WHERE FilterCriteria
saves an enormous amount of I/O and CPU cycles: one lock, one transaction, one row re-write, one set of reindexes.
Yes, I retooled some code to replace (pun not intended) a whole bunch of REPLACE commands in the same area with a SCATTER to object, do the voodoo, then just ONE REPLACE afterwards for that very purpose. I specifically listed that "multiple conditions" example thinking if I didn't, someone would say as you did to avoid the multiple REPLACEs. :-)
Second, in VFP, all indexes have to be evaluated, as there's no backlink to which fields are used in which expressions. Indexes are defined at the table level, not the row, so can have multiple field names, functions (UPPER() or DELETED(), for example), concatentations or just random stuff.
So you're contending that ALL of the indexes--not just those affected by the field that was changed--would have to be reevaluated?
<OldWarStory> I once worked on an app where the original developer thought it would be a "clever" idea to define index expressions as UDFs. Yes, it's possible. In his UDFs, he would switch work areas, open tables if not already opened, look up values, and then return the value, cleaning up work areas and tables as he went. For every index definition for every record. A reindex with more than a couple hundred records brought the entire system to its knees. </OldWarStory>
YIKES!!!! Thanks for sharing that one!