Avoiding Unbounded Queries and Large Expands

You should avoid using unbounded queries and large expands.

Unbounded queries can pose problems, especially with large databases. For example, a command similar to temp query bus * * * will search every single item in the database. If the database is small, this is not an issue. As the database size increases, this becomes a tremendous performance problem. To avoid this problem you can restrict the query by vault or type, impose a find limit on the query, or create a query trigger.

Restricting the query to objects within the same vault is an obvious way to restrict a query. Limiting the search to objects that are all known to be stored a certain way cuts down on processing because all SQL commands related to the query have to be duplicated for each vault involved in the search.

Similar to a large query, a large expand also causes performance problems. For example, the command expand bus T N R recurse all; attempts to expand all items connected to the specified object, expand all of those objects, and on, and on. Once again, a small database can hide the potential problem with this query because its results do not manifest themselves until the database size gets very large. A suggested solution is to limit the number of levels to expand (do not use recurse all, use recurse to 2).