In Quintus Prolog, predicates are indexed on their first arguments.
This means that when a predicate is called
with an instantiated first argument, a hash table is
used to gain fast access to only those clauses having a first argument
with the same primary functor as the one in the predicate call.
If the first argument is atomic, only clauses with a matching first argument
are accessed. Indexes are maintained automatically by the built-in
predicates manipulating the Prolog database (for example,
Keeping this feature in mind when writing programs can help speed their execution. Some hints for program structuring that will best use the indexing facility are given below. Note that dynamic predicates as well as static predicates are indexed. The programming hints given in this section apply equally to static and dynamic code.