The above strategy of compiling fact-defined predicates works fine for relations that aren't too large. Such predicates should be dynamically loaded. This means that the facts defining them are read from a file and asserted into XSB's program space. Assume that the file qdata.
Asserted clauses have more powerful indexing capabilities than do compiled clauses.
One can ask for them to be indexed on any argument, just as compiled clauses. It's generally a good idea to use a hash table size that is an odd number that is near the expected size of the relation. Then the next command, the load d yn , loads in the data file of 10,000 facts, and indexes them on the second argument. It is also possible to put the index command in the file itself, so that it will be used when the file is dynamically loaded. Unlike compiled cclauses, asserted clauses can be indexed on more than one argument.