KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Indexes can improve On a Series functions
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: June 25, 2020

Typically, indexes are considered for fields that are most frequently queried to improve speed of generating selections. Something else that indexes can improve are the 4D functions that perform calculations on a series of values. This is mentioned in the documentation for the On a Series theme "To limit processing time, you can use an index" and in each command under the theme "If series is an indexed field, the index is used".

A short summary of how this works is when an index is available, all of the values of the indexed field are loaded immediately and then the index is also used to fetch the immediate values of the selection needed for the function.

If there is not an index, all of the records need to be loaded, and then the value from the field of interest needs to be extracted record by record into an array to perform the calculation which is not as efficient as a whole record can be significantly larger than just the value of the field and slower as it requires more time to process and handle everything.