-
Notifications
You must be signed in to change notification settings - Fork 173
Self Driving Database
The Tuning subsystem allows different aspects of the database to be tuned. The system can be extended to support concrete use cases by implementing the provided abstract classes.

Tuning, performed by the Tuner class, takes place in three conceptual steps: evaluation, selection and execution.
- An Evaluator (implement by inheriting
AbstractTuningEvaluator) analyzes the state of the system and proposes severalTuningOptions. ATuningOptionhas a certain desirability (e.g. positive: speeds up system, negative: makes system slower), confidence and a cost (permanent usage of some budget, e.g. a memory budget). It can be accepted and rejected later on, and has a flag that indicates whether it is currently chosen, i.e. if it represents the current state of the system in that aspect. For instance: Having or not having a specific index on a column (the option) may speed up the system based on recent queries that used that column (desirability), and the index may or might not already exist (currently chosen). Accepting the option will create/keep the index, rejecting it will drop/not create the index. - All
TuningOptionsare then transformed into an sorted list ofTuningOperations. This is the job of theAbstractTuningSelector, with aGreedyTuningSelectorbeing implemented and usable by default. The selector decides which options to accept and to reject (yielding aTuningOperationeach) and orders these operations in such a way that the overall cost budget (e.g. memory budget) is not exceeded at any time when executing the operations in the given order. - Finally, the
TuningOperations are executed one after the other. Execution, as all other steps, adheres to a time budget, and thus might be cancelled at any time.
For your specific use case, you need to at least inherit from AbstractTuningEvaluator, TuningOption and TuningOperation for accepting and rejecting such a option.
The automatic creation and removal of indexes is implemented as an example: the IndexTuningEvaluator looks at the query cache and column statistics to determine which indexes could be created, and returns a list of IndexTuningOptions. These are selected by a GreedyTuningSelector which then, upon execution, creates or removes indexes. The tuning process adheres to a memory budget configurable in the Tuner.