| Discussion |
Keywords: XFormDBF, VFP
Remote Name: 188.8.131.52
The program to replace all fields in a single record is generated and compiled only once per Run, when xfom_run makes its initial invocation of the xfom_buildrepl method. In the loop over input records, xfom_run1 invokes this already-compiled program against the next record. The program doesn't change from record to record. The cost of generating and compiling is negligible for anything but the most trivial job (which is why I didn't bother making compilation a user-settable option). The programming effort to generate and compile a program is no longer an issue, because I created a general-purpose utility (cmdprg.prg in mdacomm) to generate/compile/run/cleanup any PRG.
Anyway, your idea may still be of value regardless of the compilation aspect. The question is whether a SCATTER is faster than one or two long REPLACE statements. It may well be faster, and it also probably avoids the REPLACE command limitations. I would agree that this is worth benchmarking. If you have any comparative timing statistics, I'd be interested to see them.
Another optimization that would be worth considering is using SQL INSERT statements instead of APPEND/REPLACE. This is perhaps a more important avenue to investigate, because the SQL approach is often more efficient. Carrying this idea even further, a single SQL statement that can generate all output records at once would probably be the biggest win of all, but this requires further thought. If it can't be done in general, maybe it could be done in at least some kinds of transformations.