Method, apparatus, electronic device, and medium for processing database query
AssigneeBeijing Volcano Engine Technology Co., Ltd.
InventorsYuxing Han, Haoyu Wang
Life of this patent
Estimating the term…
Abstract
Embodiments of the present disclosure provide a method and apparatus for database query, an electronic device, and a medium. The method includes: determining, in response to receiving a structured query language (SQL) query for a database, a query condition and a target column of the SQL query that relates to a number of distinct values (NDV) estimation; selecting, from sampled data of the database, data of the target column that meets the query condition; generating feature data of the selected data of the target column; and determining an estimated NDV of the target column based on the feature data using a model for NDV estimation.
Claims15
A computer-implemented method implemented by a database system device for processing a database query, comprising:
- receiving, by a database system kernel, a structured query language (SQL) query for a database, wherein the SQL query specifies a query condition and a target column related to number of distinct values (NDV) estimation, and the SQL query comprises an aggregation query for the target column;
- selecting, by the database system kernel from sampled data of the database, data of the target column that satisfies the query condition;
- generating, by the database system kernel, a feature vector based on the data of the target column selected from the sampled data, wherein each i-th component of the feature vector represents the number of distinct values that occur i times in the target column, wherein i is an integer;
- determining, by the database system kernel, an estimated NDV of the target column of the database using a trained machine learning model for the NDV estimation and using the feature vector as an input to the trained machine learning model for the NDV estimation;
- and
- allocating, by the database system kernel, a hash table capacity based on the estimated NDV for the aggregation query.
An electronic device, comprising:
- one or more processors;
- and
- a memory storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform a method implemented by a database system device for processing a database query, the method comprising:
- receiving, by a database system kernel, a structured query language (SQL) query for a database, wherein the SQL query specifies a query condition and a target column related to number of distinct values (NDV) estimation, and the SQL query comprises an aggregation query for the target column;
- selecting, by the database system kernel from sampled data of the database, data of the target column that satisfies the query condition;
- generating, by the database system kernel, a feature vector based on the data of the target column selected from the sampled data, wherein each i-th component of the feature vector represents the number of distinct values that occur i times in the target column, wherein i is an integer;
- determining, by the database system kernel, an estimated NDV of the target column of the database using a trained machine learning model for the NDV estimation and using the feature vector as an input to the trained machine learning model for the NDV estimation;
- and
- allocating, by the database system kernel, a hash table capacity based on the estimated NDV for the aggregation query.
A non-transitory computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor of a device, causes the device to perform a method implemented by a database system device for processing a database query, the method comprising:
- receiving, by a database system kernel, a structured query language (SQL) query for a database, wherein the SQL query specifies a query condition and a target column related to number of distinct values (NDV) estimation, and the SQL query comprises an aggregation query for the target column;
- selecting, by the database system kernel from sampled data of the database, data of the target column that satisfies the query condition;
- generating, by the database system kernel, a feature vector based on the data of the target column selected from the sampled data, wherein each i-th component of the feature vector represents the number of distinct values that occur i times in the target column, wherein i is an integer;
- determining, by the database system kernel, an estimated NDV of the target column of the database using a trained machine learning model for the NDV estimation and using the feature vector as an input to the trained machine learning model for the NDV estimation;
- and
- allocating, by the database system kernel, a hash table capacity based on the estimated NDV for the aggregation query.
Dependencies are inferred from the claim text.