Re: Indexes on VFP tables--when do they get updated

Author: Ted Roche

Posted: 2018-01-24 at 14:21:19

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.

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.

<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>

On Wed, Jan 24, 2018 at 1:29 PM,

<mbsoftwaresolutions@mbsoftwaresolutions.com> wrote:

>

> I understand that ADDing and DELETEing records updated all indexes; I would

> think the UPDATEs--regardless of what fields updated--would cause index

> updates for every indexed field on every update as well.

>

I don't know if it actually caused *UPDATES* but I think VFP would

have to go through each index expression and test to see if the value

had changed. Perhaps they'd skip the write if it was unchanged.

Other database engines do this differently

--

Ted Roche

Ted Roche & Associates, LLC

http://www.tedroche.com

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/CACW6n4vqfjiXAq93GoLMpmA3j8LD8_1magxRJQF3gaNWnGCk7Q@mail.gmail.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2018 Ted Roche