Indexing Engine CP Model: Custom Configuration
The model takes as input a settings JSON object. All settings are optional, and will be assigned their default value if omitted. The settings must follow this structure:
{
"Method": "CP",
"Options": {
"Goals": [
{
"Name": "Minimize Total Cost",
"Tolerance": 0.1
},
{
"Name": "Minimize Index Write Overhead",
"Tolerance": 0.0
}
],
"Rules": [
{
"Name": "Maximum Number of Indexes",
"Value": 10
}
]
}
}
The two main fields are Method
and Options
. Method
defines the method used for performing index selection, and can be one of CP or Greedy. The current default is Greedy
for backwards compatibility purposes. The Options
can customize the behavior of the chosen method.
CP Method
Roughly, the CP
method works as follows:
- Validate the data and the settings
- Create a basic model
- Add all the rules to the model
- For each goal:
- Optimize the goal
- Transform the goal into a rule (taking tolerance into account)
- Return the selection of indexes
It has multiple options to allow customization:
Name | Type | Min | Max | Default | Description |
---|---|---|---|---|---|
Goals | array[Goal] | n/a | n/a | [] | Ordered list of goals |
Rules | array[Rule] | n/a | n/a | [] | List of rules |
Time Limit | float | 0.0 | ∞ | ∞ | Time allotted to the model |
Each goal is defined by its name and tolerance (0.0 to ∞). The available goals are:
- Minimize Index Write Overhead
- Minimize Number of Indexes
- Minimize Total Cost
- Minimize Maximum Cost
- Minimize Maximum Relative Cost
- Minimize Total Weighted Cost
- Minimize Maximum Weighted Cost
- Minimize Maximum Relative Weighted Cost
- Minimize Update Overhead
The rules are defined by their name and an associated value. If a rule is not defined in the settings, it will be automatically created and it will be assigned its default value:
Rule Name | Type | Min | Max | Default | Description |
---|---|---|---|---|---|
Maximum Per-Scan Cost Tolerance | float | 0.0 | ∞ | ∞ | Scan cost tolerance w.r.t. best cost |
Maximum Per-Scan Weighted Cost Tolerance | float | 0.0 | ∞ | ∞ | Scan weighted cost tolerance w.r.t. best weighted cost |
Maximum Number of Indexes | integer | 0 | ∞ | ∞ | Maximum number of indexes suggested |
Maximum Index Write Overhead | float | 0.0 | ∞ | ∞ | Maximum index write overhead allowed |
Minimum Coverage | float | 0.0 | 1.0 | 0.0 | Portion of coverable scans covered |
Tolerance
The tolerance parameter is a measure of how strict the ordering of the goals is. It allows some amount of flexibility in the ordering of the goals. Each goal has an associated tolerance value in the range [0.0, ∞] (defaulted to 0). When a goal is optimized, the resulting value indicates how well that goal has met its stated objective. The tolerance of that goal, in turn, indicates how close subsequent goals should stick to the value found for the original goal.
Example
There are two goals:
- Minimize Total Cost (with a tolerance of 0.1)
- Minimize Index Write Overhead
Suppose that the total cost found by the first goal is 200. Normally (with a tolerance of 0) the second goal should determine the lowest index write overhead required to achieve costs no higher than 200.
However, with a tolerance of 0.1, the second goal will instead determine the lowest index write overhead required to achieve costs no higher than 220 (because 200 + 10% = 220).
Couldn't find what you were looking for or want to talk about something specific?
Start a conversation with us →