Automated Database Indexing Using Model-Free Reinforcement Learning

Automated Database Indexing Using Model-Free Reinforcement Learning

Automated Database Indexing Using Model-Free Reinforcement Learning Gabriel Paludo Licksy and Felipe Meneguzziz Pontifical Catholic University of Rio Grande do Sul (PUCRS), Brazil Graduate Program in Computer Science, School of Technology [email protected] [email protected] Abstract is a fundamental task that needs to be performed continu- ously, as the indexing configuration directly impacts on a Configuring databases for efficient querying is a complex database’s overall performance. task, often carried out by a database administrator. Solving We developed an architecture for automated and dynamic the problem of building indexes that truly optimize database database indexing that evaluates query and insert/update per- access requires a substantial amount of database and do- main knowledge, the lack of which often results in wasted formance to make decisions on whether to create or drop space and memory for irrelevant indexes, possibly jeopardiz- indexes using Reinforcement Learning (RL). We performed ing database performance for querying and certainly degrad- experiments using a scalable benchmark database, where we ing performance for updating. We develop an architecture to empirically evaluate our architecture results in comparison solve the problem of automatically indexing a database by to standard baseline index configurations, database advisor using reinforcement learning to optimize queries by indexing tools, genetic algorithms, and other reinforcement learning data throughout the lifetime of a database. In our experimen- methods applied to database indexing. The architecture we tal evaluation, our architecture shows superior performance implemented to automatically manage indexes through re- compared to related work on reinforcement learning and ge- inforcement learning successfully converged in its training netic algorithms, maintaining near-optimal index configura- to a configuration that outperforms all baselines and related tions and efficiently scaling to large databases. work, both in performance and in storage usage by indexes. 1 Introduction 2 Background Despite the multitude of tools available to manage and gain 2.1 Reinforcement Learning insights from very large datasets, indexing databases that Reinforcement learning aims to learn optimal agent poli- store such data remains a challenge with multiple opportu- cies in stochastic environments modeled as Markov Deci- nities for improvement [27]. Slow information retrieval in sion Processes (MDPs) [2]. It is a trial-and-error learning databases entails not only wasted time for a business but also method, where an agent interacts and transitions through indicates a high computational cost being paid. Unnecessary states of an MDP environment model by taking actions and indexed columns, or columns that should be indexed but are observing rewards [23, Ch. 1]. MDP are formally defined as not, directly impact the query performance of a database. a tuple M = hS; A; P; R; γi, where S is the state space, Nevertheless, achieving the best indexing configuration for A is the action space, P is a transition probability function a database is not a trivial task [4, 5]. To do so, we have to which defines the dynamics of the MDP, R is a reward func- learn from queries that are running, take into account their tion and γ 2 [0; 1] is a discount factor [23, Ch. 3]. performance, the system resources, and the storage budget In order to solve an MDP, an agent needs to know the so that we can find the best index candidates [18]. state-transition and the reward functions. However, in most In an ideal scenario, all frequently queried columns realistic applications, modeling knowledge about the state- should be indexed to optimize query performance. Since cre- transition or the reward function is either impossible or im- ating and maintaining indexes incur a cost in terms of stor- practical, so an agent interacts with the environment tak- age as well as in computation whenever database insertions ing sequential actions to collect information and explore the or updates take place in indexed columns [21], choosing an search space by trial and error [23, Ch. 1]. The Q-learning optimal set of indexes for querying purposes is not enough algorithm is the natural choice for solving such MDPs [23, to ensure optimal performance, so we must reach a trade- Ch. 16]. This method learns the values of state-action pairs, off between query and insert/update performance. Thus, this denoted by Q(s; a), representing the value of taking action a in a state s [23, Ch. 6]. Copyright c 2020, Association for the Advancement of Artificial Assuming that states can be described in terms of features Intelligence (www.aaai.org). All rights reserved. that are well informative, such problem can be handled by using linear function approximation, which is to use a pa- is the execution time of refresh functions j (insert/update) in rameterized representation for the state-action value func- the query stream s, and SF is the scale factor or database tion other than a look-up table [25]. The simplest differen- size, ranging from 1 to 100; 000 according to its @Size. tiable function approximator is through a linear combination The T hroughput@Size measures the ability of the sys- of features, though there are other ways of approximating tem to process the most queries in the least amount of time, functions such as using neural networks [23, Ch. 9, p. 195]. taking advantage of I/O and CPU parallelism [24]. It com- putes the performance of the system against a multi-user 2.2 Indexing in Relational Databases workload performed in an elapsed time, using Equation 2: An important technique to file organization in a DBMS is in- S × 22 dexing [21, Ch. 8, p. 274], and is usually managed by a DBA. T hroughput@Size = × 3600 × SF (2) T However, index selection without the need of a domain ex- S pert is a long-time research subject and remains a challenge where S is the number of query streams executed, and TS is due to the problem complexity [27, 5, 4]. The idea is that, the total time required to run the test for s streams. given the database schema and the workload it receives, we can define the problem of finding an efficient index config- p uration that optimizes database operations [21, Ch. 20, p. QphH@Size = P ower@Size × T hroughput@Size (3) 664]. The complexity stems from the potential number of Equation 3 shows the Query-per-Hour Performance attributes that can be indexed and all of its subsets. (QphH@Size) metric, which is obtained from the geomet- While DBMSs strive to provide automatic index tuning, ric mean of the previous two metrics and reflects multiple the usual scenario is that performance statistics for optimiz- aspects of the capability of a database to process queries. ing queries and index recommendations are offered, but the The QphH@Size metric is the final output metric of the DBA makes the decision on whether to apply the changes benchmark and summarizes both single-user and multiple- or not. Most recent versions of DBMSs such as Oracle [13] user overall database performance. and Azure SQL Database [19] can automatically adjust in- dexes. However, it is not the case that the underlying system 3 Architecture is openly described. A general way of evaluating DBMS performance is In this section, we introduce our database indexing architec- through benchmarking. Since DBMSs are complex pieces ture to automatically choose indexes in relational databases, of software, and each has its own techniques for optimiza- which we refer to as SmartIX. The main motivation of Smar- tion, external organizations have defined protocols to eval- tIX is to abstract the database administrator’s task that in- uate their performance [21, Ch. 20, p. 682]. The goals of volves a frequent analysis of all candidate columns and ver- benchmarks are to provide measures that are portable to dif- ifying which ones are likely to improve the database index ferent DBMSs and evaluate a wider range of aspects of the configuration. For this purpose, we use reinforcement learn- system, e.g., transactions per second and price-performance ing to explore the space of possible index configurations in ratio [21, Ch. 20, p. 683]. the database, aiming to find an optimal strategy over a long time horizon while improving the performance of an agent 2.3 TPC-H Benchmark in the environment. The SmartIX architecture is composed of a reinforcement The tools provided by TPC-H include a database genera- learning agent, an environment model of a database, and a tor (DBGen) able to create up to 100 TB of data to load DBMS interface to apply agent actions to the database. The in a DBMS, and a query generator (QGen) that creates reinforcement learning agent is responsible for the decision 22 queries with different levels of complexity. Using the making process. The agent interacts with an environment database and workload generated using these tools, TPC- model of the database, which computes system transitions H specifies a benchmark that consists of inserting records, and rewards that the agent receives for its decisions. To make executing queries, and deleting records in the database to measure the performance of these operations. The TPC-H Performance metric is expressed in Queries- SmartIX per-Hour (QphH@Size), which is achieved by computing RL Agent the P ower@Size and the T hroughput@Size metrics [24]. State st+1 Action at The resulting values are related to its scale factor (@Size), Reward rt+1 i.e., the database size in gigabytes. The P ower@Size eval- Environment uates how fast the DBMS computes the answers to single Indexing Structured queries. This metric is computed using Equation 1: option DB stats DBMS Interface 3600 Changes Database P ower@Size = q × SF (1) to apply stats 24 22 2 πi=1QI(i; 0) × πj=1RI(j; 0) DBMS where 3600 is the number of seconds per hour and QI(i; s) is the execution time for each one of the queries i.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us