The Two Engines

One such difference is what constitutes an expression that can be optimized. The help file states that such expressions have one of the following forms:
Many databases have optimizers, but Visual FoxPro has two of them. Usually, both work similarly pretending to be one powerful engine. There are times, however, when you need to know the differences between the two engines to write efficient code. The engines I'm talking about are the xBase and the SQL Rushmore optimizer engines.


eIndex relOp eExp

eExpr relOp eIndex

In other words, both of the following expressions are optimizable:


Name = "Smith"
"Smith" = Name

If you analyze what happens when you run a query with this condition you will see that there are differences between using a FOR clause in a traditional command and a WHERE clause in a SQL statement. A command with a FOR clause runs blazingly fast. It's fully optimized.

The SQL statement, on the other hand, displays a progress bar for the same query. SYS(3054), the function used to determine the optimization level, states that the query is not optimized at all.

In other words: In XBase it doesn't matter whether you write the field name first. In SQL queries, however, it does matter a great deal. To avoid confusion it's a good idea to always use the notation with the field name first.