Applying Logical Knowledge
Performance
Some performance considerations:
- In linked goals, have the ones with the most bindings first. The more earlier
goals or bound, the less searching will be required in later goals.
- Most Prolog support first argument indexing, so have the most common "query"
goal first.
- Have bound arguments earlier than unbound ones in predicates, as unification
proceeds left to right.
- Recursive list loops are often faster than backtracking database loops.
- Tail recursion is much faster than non-tail recursion.
- Compiled code is about 10x faster than interpreted code.