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 index/1.
For advanced database indexing, it defines hash_term/2:
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.