Database Management Systems (DBMSs) process a given query by creating an execution plan, which is subsequently executed, to compute the query's result. Deriving an efficient query plan is challenging, and both academia and industry have invested decades into researching query optimization. Despite this, DBMSs are prone to performance issues, where a DBMS produces an inefficient query plan that might lead to the slow execution of a query. Finding such issues is a longstanding problem and inherently difficult, because no ground truth information on an expected execution time exists. In this work, we propose Cardinality Estimation Restriction Testing (CERT), a novel technique that detects performance issues through the lens of cardinality estimation. Given a query on a database, CERT derives a more restrictive query (e.g., by replacing a LEFT JOIN with an INNER JOIN), whose estimated number of rows should not exceed the number of estimated rows for the original query. CERT tests cardinality estimators specifically, because they were shown to be the most important component for query optimization; thus, we expect that finding and fixing such issues might result in the highest performance gains. In addition, we found that some other kinds of query optimization issues are exposed by the unexpected cardinality estimation, which can also be detected by CERT. CERT is a black-box technique that does not require access to the source code; DBMSs expose query plans via the EXPLAIN statement. CERT eschews executing queries, which is costly and prone to performance fluctuations. We evaluated CERT on three widely used and mature DBMSs, MySQL, TiDB, and CockroachDB. CERT found 13 unique issues, of which 2 issues were fixed and 9 confirmed by the developers. We expect that this new angle on finding performance bugs will help DBMS developers in improving DMBSs' performance.
翻译:数据库管理系统(DBMS)通过创建执行计划来处理给定查询,随后执行该计划以计算查询结果。生成高效的查询计划极具挑战性,学术界和工业界已投入数十年研究查询优化技术。尽管如此,DBMS仍易出现性能问题,即系统生成低效查询计划导致查询执行缓慢。发现此类问题是一个长期存在的根本性难题,因为缺乏预期执行时间的基准真相信息。本文提出基数估计限制测试(CERT)这一新型技术,通过基数估计的视角检测性能问题。给定数据库上的查询时,CERT推导出更具限制性的查询(例如将左连接替换为内连接),其估计行数不应超过原始查询的估计行数。CERT专门测试基数估计器,因为研究表明该组件是查询优化中最关键的部分;因此,我们预期发现并修复此类问题可带来最高性能增益。此外,我们发现某些其他类型的查询优化问题也会因异常基数估计而暴露,这些同样能被CERT检测。CERT是一种黑盒技术,无需访问源代码;DBMS通过EXPLAIN语句暴露查询计划。CERT避免执行查询这一高成本且易受性能波动影响的步骤。我们在三种广泛使用的成熟DBMS(MySQL、TiDB和CockroachDB)上评估了CERT。CERT发现了13个独特问题,其中2个已修复,9个获得开发者确认。我们预期这种发现性能缺陷的新视角将有助于DBMS开发者提升系统性能。