next up previous contents index
Next: Declaring predicates properties Up: Database Previous: Update view   Contents   Index

Indexing databases

By default, SWI-Prolog, as most other implementations, indexes predicates on their first argument. SWI-Prolog allows indexing on other and multiple arguments using the declaration index1.

For advanced database indexing, it defines hash_term2:

hash_term2+Term, -HashKey If Term is a ground term (see ground1), HashKey is unified with a positive integer value that may be used as a hash-key to the value. If Term is not ground, the predicate succeeds immediately, leaving HashKey an unbound variable.

This predicate may be used to build hash-tables as well as to exploit argument-indexing to find complex terms more quickly.

The hash-key does not rely on temporary information like addresses of atoms and may be assumed constant over different invocations of SWI-Prolog.



Dr. Richard Botting 2001-12-12