Tuning: Key selection algorithms

A key selection algorithm selects a key to perform a query based on the order of the fields in the query expression, and the order of the fields in the keys defined in the dbdict. The system then assigns a weight to each key based on the order in which the fields appear in the query for the key, and the order in which they appear in the query and key. For example, if the first field in a key matches the first field in the query, Service Manager assigns that key a higher weight than one that has that field as the second field in the key. The system makes the decision for all fields in the query and keys.

Example query and keys:

query:	a=1 and b=2 and c=3 and d=4
	key1: b,c,d
	key2: a,c,d
	key3: a,b
	key4: a

In this example, the key selection algorithm selects key3. The next highest weight is key2, followed by key4 and key1. The new key selection is based on the location database dictionary record with the keys {location}, {location,state}, {location,city}, {location.name,location}, and {location.code}.

Related topics

Key type definitions
Tuning: Designing keys for queries
Tuning: Improving query speed
Tuning: Number of fields in files