====== Indexed-Based SELECT ====== If the sort criteria passed in an extended BASIC+ [[select|SELECT statement]] represent indexed fields, there is no need for the SELECT processor to execute an entire SELECT ... READNEXT ... READ loop in order to build a resolved list of keys. Instead, the list can be constructed directly from the Btree index. The result of this condition is a latent index-based select. This is similar to a latent file-based select condition as established by a simple BASIC+ [[select|SELECT]]. However, it differs in that a latent index-based select can return keys in sorted order. A latent index-based select condition is not a BFS-level function. If an indexed field is passed as a sort criterion in a filing system SELECT call, [[system_mfss_in_openinsight|SI.MFS]] traps the call. Other MFSs that follow [[system_mfss_in_openinsight|SI.MFS]], and the actual BFS, never receive the SELECT call. SI.MFS returns a select mode of 2 in the RECORD argument (causing [[cursors_and_select_lists|@LIST.ACTIVE]] to be set to 2), indicating an index-based select condition. [[system_mfss_in_openinsight|SI.MFS]] will then trap subsequent filing system [[readnext|READNEXT]] calls, providing blocks of keys out of the Btree index. Again, filing systems that follow [[system_mfss_in_openinsight|SI.MFS]] will never receive this call, since it is trapped and fulfilled by [[system_mfss_in_openinsight|SI.MFS]].