Database benchmark test set generation method based on synchronous generation of data and query

By building and accumulating networks and generating new data and queries, the problem that the existing technology cannot reflect user business logic and data distribution is solved, and a user-specific benchmark test set is generated to avoid leakage of sensitive information.

CN115712554BActive Publication Date: 2025-06-06SHENZHEN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211192370.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-28
Publication Date
2025-06-06
Estimated Expiration
2042-09-28

AI Technical Summary

Technical Problem

Existing database benchmarks cannot reflect the user's business logic and data distribution, and cannot generate more queries based on existing query templates to prevent sensitive information leakage.

Method used

By building and accumulating networks, capture the data distribution of the database and sample the network to generate new data. Solve the query scope in the new data based on the cardinality of the original query and generate a new query and benchmark test set.

Benefits of technology

The generated benchmark test set can reflect the user's business logic and data distribution, while avoiding the leakage of user sensitive information, and can be tested for specific scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115712554B_ABST
    Figure CN115712554B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for generating a database benchmark test set based on synchronous generation of data and queries, including: constructing a first sum-product network according to a database; sampling the constructed first sum-product network and generating new data; obtaining a first query of a workload, obtaining a query range through query parsing, and obtaining the cardinality of the first query based on the query range; querying new data based on the query result obtained by the first query, solving the range of the second query, and the obtained second query and the new data together constitute a benchmark test set; estimating the selection rate of each node in the sum-product network constructed by the new data, and calculating the cardinality of the second query, generating a query heat map based on the query results and cardinality estimates obtained by the first sum-product network and the second sum-product network to verify the generated effect. The present invention enables the data distribution of the original database to be captured, and more queries can be generated based on the existing query template.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to a method, device, equipment and medium for generating a database benchmark test set based on synchronous generation of data and queries. Background Art

[0002] Database systems are widely used in production environments because of their transactional, disaster recovery, backup and other features. Therefore, database benchmarking is crucial to verifying their functions and performance. When enterprises choose database products, they compare the differences between various databases, and the results of benchmarking are one of the most important indicators.

[0003] However, current database benchmarks are generally targeted at specific scenarios and cannot reflect the user's own business logic. Existing benchmark test sets cannot reflect the data distribution of the user's database, nor can they generate more queries based on existing query templates to prevent the leakage of user sensitive information. This is inconvenient for users, and this is a problem that urgently needs to be solved.

[0004] Therefore, the prior art still needs to be improved and developed. Summary of the invention

[0005] The technical problem to be solved by the present application is that, in view of the deficiencies in the prior art, a method, device, and medium for generating a database benchmark test set based on synchronous generation of data and queries are provided. The present invention can generate more queries based on existing query templates to prevent leakage of user sensitive information. At the same time, the benchmark test set generated by the present invention can reflect the user's own business logic for specific scenarios, and can reflect the data distribution of the user database. At the same time, the generated data and queries can also be visually compared with the original ones to verify that the two have similar characteristics and execution results.

[0006] In order to solve the deficiencies of the above-mentioned prior art problems, the first aspect of the embodiments of the present application provides a method for generating a database benchmark test set based on synchronous generation of data and queries, the method comprising:

[0007] A first sum-product network is constructed according to the database, and the constructed sum-product network logically forms a binary tree;

[0008] Sampling the constructed first sum-product network and generating new data, and constructing a second sum-product network based on the new data;

[0009] Obtaining a first query of the workload, obtaining a query range through query parsing, estimating a selectivity of each node in a first sum-product network based on the query range, and calculating a cardinality of the first query;

[0010] Based on the number of query results, node selection rate and cardinality obtained from the first query, query the new data to solve the range of the second query, build a benchmark test set based on the new data and the second query, estimate the selection rate of each node in the second sum-product network based on the second query range, and calculate the cardinality of the second query;

[0011] A query heat map is generated based on the query results and cardinality estimates obtained from the first sum-product network and the second sum-product network.

[0012] The step of constructing the first sum-product network according to the database specifically includes:

[0013] The data table in the current database is divided and constructed into nodes through row division and column division to obtain the first sum-product network.

[0014] The sampling of the constructed first sum-product network and generation of new data, and constructing a second sum-product network based on the new data specifically includes:

[0015] The data of the leaf nodes in the binary tree are processed by noise and randomly sampled, and the data are concatenated in rows or columns according to the parent node type of the leaf nodes until all the data are returned to the root node and a new data table is formed.

[0016] Construct a new sum-product network for the new data table.

[0017] The step of estimating the selection rate of each node in the first sum-product network based on the query range and calculating the cardinality of the first query specifically includes:

[0018] Based on the query parsing result, by traversing the first sum-product network, the child node corresponding to the column to be queried is obtained, and the selectivity of the query under the condition is estimated in the child node according to the query condition, and returned to the parent node;

[0019] The selectivity is processed according to the parent node type. If the parent node is a sum node, the selectivity of the two child nodes is weighted by their respective row numbers and then summed and returned to the parent node; if the parent node is a product node, the selectivity of the two child nodes is directly multiplied and returned to the parent node;

[0020] The selectivity of each node is calculated until the calculation result is returned to the root node. The selectivity of the root node is multiplied by the total number of rows to obtain the cardinality estimate of the query, and the cardinality of the query is saved.

[0021] The query result quantity, node selection rate and cardinality obtained based on the first query, querying the new data in the second sum-product network to solve the scope of the second query specifically includes:

[0022] The query scope of the first query is removed, the query structure and cardinality of the first query are retained, and the scope of the second query is solved in the second sum-product network based on the number and cardinality of the first query results.

[0023] The query result quantity, node selection rate and cardinality obtained based on the first query, querying the new data in the second sum-product network to solve the scope of the second query specifically includes:

[0024] The second query queries the newly generated data, requiring that the selectivity of the column obtained by the second query is the same as the selectivity of the same column in the first query, and the cardinality obtained by the second query is the same as the cardinality obtained by the first query;

[0025] If the number of results obtained by the selected second query range is small, then the query range is increased;

[0026] If the number of results obtained by the selected second query range is large, narrow the query range;

[0027] When the number of results, column selection rate, and cardinality obtained by the second query are equal to the query results of the first query, the query range is solved and the query range at this time is used as the query range of the second query;

[0028] Based on the query range of the second query, the selectivity of each node in the second sum-product network is estimated, and the cardinality of the second query is calculated.

[0029] The query results and cardinality estimates obtained based on the first sum-product network and the second sum-product network are used to generate a query heat map, specifically comprising:

[0030] The depth of the node color is mapped to the size of the selection rate. The node with a larger selection rate has a darker color, and vice versa. The entire first sum-product network and the second sum-product network are visualized by drawing to form a heat map of the query.

[0031] A second aspect of an embodiment of the present application provides a database benchmark test set generation device based on data and query synchronous generation, the database benchmark test set generation device based on data and query synchronous generation comprising:

[0032] A network construction module is used to construct a sum-product network according to the database. The constructed sum-product network logically forms a binary tree.

[0033] A data acquisition module, used for sampling the constructed first sum-product network and generating new data;

[0034] A cardinality estimation and new query range acquisition module obtains a first query of the workload, obtains a query range through query parsing, estimates the selectivity of each node in a first sum-product network based on the query range, and calculates the cardinality of the first query, queries new data based on the number of query results, node selectivity, and cardinality obtained from the first query, solves the range of a second query, constructs a benchmark test set based on the new data and the second query, estimates the selectivity of each node in a second sum-product network based on the second query range, and calculates the cardinality of the second query;

[0035] A heat map generation module is used to generate a query heat map based on the query results and cardinality estimates obtained by the first sum-product network and the second sum-product network.

[0036] A third aspect of an embodiment of the present application provides a terminal device, comprising: a processor, a memory, and a communication bus; the memory stores a computer-readable program that can be executed by the processor;

[0037] A third aspect of an embodiment of the present application provides a computer-readable storage medium, which includes a memory, a processor, and a database benchmark test set generation program based on data and query synchronous generation stored in the memory and executable on the processor, so as to implement the steps in any of the above-described methods for generating a database benchmark test set based on data and query synchronous generation.

[0038] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium on which is stored a database benchmark test set generation program based on synchronous generation of data and queries, so as to implement the steps of any of the above-described methods for generating a database benchmark test set based on synchronous generation of data and queries.

[0039] Beneficial effect: Compared with the prior art, the present application provides a method, device, and medium for generating a database benchmark test set based on synchronous generation of data and queries. The method includes constructing a first sum-product network according to a database, and the constructed sum-product network logically forms a binary tree; sampling the constructed first sum-product network and generating new data, and constructing a second sum-product network based on the new data; obtaining a first query of the workload, obtaining a query range through query parsing, estimating the selectivity of each node in the first sum-product network based on the query range, and calculating the cardinality of the first query; querying the new data based on the number of query results, node selectivity, and cardinality obtained from the first query, solving the range of the second query, constructing a benchmark test set from the new data and the second query, estimating the selectivity of each node in the second sum-product network based on the second query range, and calculating the cardinality of the second query; generating a query heat map based on the query results and cardinality estimates obtained from the first sum-product network and the second sum-product network. In this way, using the database to construct a sum-product network can well capture the data distribution of the original database; sampling the sum-product network, replacing the original data and adding random data noise perturbations, and solving the query range in the newly generated database through the cardinality corresponding to the original data, which not only retains the structure of the original query, but also generates corresponding queries in a collaboratively generated database, and the generated queries conform to the original cardinality, so that users can use existing data and queries to generate user-exclusive benchmark test sets. The data and queries contained in the benchmark test set can be completely separated from the original data and queries, and can be disclosed arbitrarily without leaking the user's sensitive information, and can reflect the user's own business logic for specific scenarios, while reflecting the data distribution of the user's database; in addition, the sum-product network is also used to generate query heat maps for visual comparison to verify the correctness of the generated data and queries. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without inventive work.

[0041] Figure 1 A flowchart of a method for generating a database benchmark test set based on synchronous generation of data and queries provided by the present invention;

[0042] Figure 2 An inventive framework diagram provided for an embodiment of the present invention;

[0043] Figure 3 A flowchart of a program for constructing and integrating a network provided by an embodiment of the present invention;

[0044] Figure 4 A schematic diagram of cardinality estimation using a sum-product network provided in an embodiment of the present invention;

[0045] Figure 5 A schematic diagram of sampling a sum-product network provided by an embodiment of the present invention;

[0046] Figure 6 A heat map for generating any query using a sum-product network provided in an embodiment of the present invention;

[0047] Figure 7 A user test flow chart provided for an embodiment of the present invention;

[0048] Figure 8 A principle block diagram of a database benchmark test set generation device based on synchronous generation of data and queries provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0049] The present application provides a method, device, and medium for generating a database benchmark test set based on synchronous generation of data and queries. In order to make the purpose, technical solution, and effect of the present application clearer and more specific, the present application is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0050] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.

[0051] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with those in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.

[0052] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present invention, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.

[0053] Database systems are widely used in production environments because of their transactional, disaster recovery, backup and other characteristics. Therefore, database benchmarking is crucial to verifying their functions and performance. The process of enterprises selecting database products is to compare the differences between databases, and the results of benchmarking are one of the most important indicators. Database benchmarking faces two major challenges. One is that it is difficult to obtain a large amount of test data and its corresponding queries; the other is that existing benchmark data sets and queries are generally targeted at specific scenarios, and users cannot conduct tests based on their own business scenarios. Existing technologies generally solve the above challenges from two directions. One direction is to generate a large number of queries for a given database, and the other direction is to generate a large amount of data that meets the given conditions given a series of queries and constraints.

[0054] The current existing database benchmarks are as follows:

[0055] LearnedSQLGen: This technology uses reinforcement learning to generate a specified number of qualified queries given the user's database and constraints. However, reinforcement learning requires a lot of time to train the generator, and the training may not converge for a long time. It is also impossible to input a query template to guide the generation. Another disadvantage is that users are required to provide constraints themselves.

[0056] SQLSmith: This technology reads the database schema and generates any number of random queries in a completely random manner, including a series of random constructions such as random query tables and columns, random selection of functions, random clauses and clauses, random predicates, etc. The disadvantage is that completely random generation will lead to a large number of meaningless query generation and cannot meet the user's testing needs.

[0057] SAM: This technology generates data by training a deep autoregressive model under the condition that the user gives the workload and its execution results. Its disadvantages are that it takes a lot of time to train, and different hyperparameters may need to be adjusted due to different given inputs, otherwise the model effect will be poor. Another disadvantage is that the workload can only be a range query.

[0058] QAGen: Given a query and result cardinality, this technology generates a symbolic database through symbolic processing, and then instantiates the symbolic database to generate a database. Its disadvantage is that only one query can be input, and the instantiation process requires very complex solution calculations, which is very expensive.

[0059] As can be seen from the above, various existing technologies cannot capture the data distribution of the user's original database, cannot generate more queries based on existing query templates, and cannot visually compare the generated data and queries with the original ones to verify that the two have similar characteristics and execution results.

[0060] In order to solve the problems in the prior art, the present invention provides a database benchmark test set generation method based on data and query synchronous generation, which can be executed by a database benchmark test set generation device based on data and query synchronous generation, and the device can be implemented by software or hardware, and can be applied to intelligent terminal devices such as tablet computers and computers installed with operating systems. In the embodiment of the invention, the sum product network is constructed using a database, which can well capture the data distribution of the original database; the sum product network is sampled, the original data is replaced and random data noise disturbance is added, and the query range is solved in the newly generated database by the cardinality corresponding to the original data, so that the structure of the original query is retained, and the corresponding query is generated by the collaboratively generated database, and the generated query conforms to the original cardinality, so that the user can use the existing data and query to generate a user-exclusive benchmark test set, and the data and query contained in the test set can be completely separated from the original data and query, and can be arbitrarily disclosed without leaking the user's sensitive information; in addition, the query heat map is generated by the sum product network for visual comparison to verify the correctness of the generated data and query.

[0061] Example Method

[0062] like Figure 1 As shown in , an embodiment of the present invention provides a method for generating a database benchmark test set based on synchronous generation of data and queries, and the method for generating a database benchmark test set based on synchronous generation of data and queries can be applied to smart terminal devices. In an embodiment of the present invention, the method includes the following steps:

[0063] Step S10: construct a first sum-product network according to the database, and the constructed sum-product network logically forms a binary tree.

[0064] In the embodiment of the present invention, when the method is implemented, a first sum-product network is constructed based on data in an existing database, so that the constructed sum-product network can logically form a binary tree.

[0065] Further, constructing the first sum-product network according to the database specifically includes:

[0066] The data table in the current database is divided and constructed into nodes by row division and column division to obtain the first sum-product network. In this way, by using the database to construct the sum-product network, the data distribution of the original database can be well captured, which is convenient for users to use.

[0067] The nodes of the sum-product network in the present invention are divided into three types, and the nodes and their division process are as follows: 1) Sum node, that is, row division, all rows in the current domain are clustered with a cluster number of 2, and the clustering method selects K-means clustering, that is, K rows are randomly selected as class centers, each row is assigned to the closest class center, and then the class centers of all classes are re-assigned, and the above operations are repeated until the class centers no longer change. Other clustering methods can also be selected. The clustering result obtained divides all rows into two parts, and the sum node is constructed with the current domain. The two parts of data are respectively used as child nodes of the sum node, and the node division continues.

[0068] 2) Product node, that is, column partitioning, calculates the Pearson correlation coefficient between all columns of the current domain, that is, the quotient of the covariance of two columns of data and the product of their respective standard deviations, to form a correlation coefficient matrix, and then sets the matrix elements whose correlation coefficients are greater than the preset threshold to 1, and the rest to 0. The matrix is ​​regarded as the adjacency matrix of the graph, and the maximum connected component of the graph is calculated. All columns in the connected component are grouped as one, and the remaining columns are grouped as one, that is, all columns of the current domain are divided into two parts, and a product node is constructed with the current domain. The two groups of data become child nodes of the product node, and the node partitioning continues.

[0069] 3) Leaf nodes, by modeling the data of the current domain, the model can be arbitrary. The present invention selects an equal-depth histogram, sorts the data in ascending order according to size, and then divides the data into N buckets in order. Each bucket records the upper and lower bounds and quantity of the data. The upper and lower bounds of the recorded data are the maximum and minimum values ​​in the bucket.

[0070] In the embodiment of the present invention, the table in the database can be divided and constructed into nodes according to the following rules:

[0071] Specifically, Figure 3 As shown, it is a flowchart of the program for constructing and integrating a network according to an embodiment of the present invention. In the initial state, all columns and all rows of a table in the database constitute the current data domain, which is referred to as the current domain in the following description. The following steps are performed:

[0072] Step S11, start, and proceed to step S12;

[0073] Step S12, determine whether the current domain exceeds one column, if not, proceed to step S13, if yes, proceed to step S21;

[0074] Step S13, determine whether the number of rows in the current domain is greater than the row division threshold, if not, proceed to step S15, if yes, proceed to step S14;

[0075] Step S14, perform row division, and control enters step S26;

[0076] Step S15, construct a leaf node and proceed to step S30;

[0077] Step S21, perform column division, and proceed to step S22;

[0078] Step S22, determine whether the column division is successful, if not, proceed to step S23, if yes, proceed to step S26;

[0079] Step S23, determine whether the number of rows in the current domain is greater than the row division threshold, if yes, proceed to step S25, if no, proceed to step S24;

[0080] Step S24, forcibly executing column division, and proceeding to step S26;

[0081] Step S25, perform row division, and proceed to step S26;

[0082] Step S26, after the division, the two domains return to execute step S12 respectively;

[0083] Step S30, end the process.

[0084] As can be seen from the above, in the embodiment of the present invention, at the beginning, it is determined whether the current domain exceeds one column. If the current domain is greater than one column, step S21 is directly executed. If the current domain is equal to one column and the number of rows is greater than the threshold for row division, row division is performed, and the two domains after division respectively execute the step of determining whether the previous domain exceeds one column in step S12;

[0085] If the current domain is equal to one column, and the number of rows is less than or equal to the preset threshold for row division, a leaf node is constructed for the data in the current domain, and the process ends after the construction is completed;

[0086] In the embodiment of the present invention, when performing column division, first determine whether the column division is successful. If the column division fails, that is, there is only one connected component during division, then perform row division; if the row division cannot be performed, that is, the number of rows is less than or equal to the threshold of row division, then lower the threshold of the correlation coefficient during column division to force column division; after the division is completed, return to step S12;

[0087] In the embodiment of the present invention, the actual execution process is recursively performed in a depth-first manner, and the end condition is that the leaf nodes are constructed, and finally a binary tree is formed logically.

[0088] Step S20: sampling the constructed first sum-product network and generating new data, and constructing a second sum-product network based on the new data.

[0089] In the embodiment of the present invention, the first sum-product network constructed in step S10 is sampled and new data is generated, and the second sum-product network is constructed using the newly generated data.

[0090] Furthermore, sampling the constructed first sum-product network and generating new data, and constructing a second sum-product network based on the new data specifically includes:

[0091] The data of the leaf nodes in the binary tree are processed by noise and randomly sampled, and the data are concatenated in rows or columns according to the parent node type of the leaf nodes until all the data are returned to the root node and a new data table is formed.

[0092] Construct a new sum-product network for the new data table.

[0093] The new data generated after adding noise has a random range compared to the original data range, which can prevent outsiders from inferring the characteristics of the original data through the data range, while non-strictly retaining the relationship between the original data.

[0094] The first sum-product network is a sum-product network constructed by original data, and the second sum-product network is a sum-product network constructed by new data.

[0095] Specifically, Figure 5As shown, the sampling process of the present invention traverses the constructed sum-product network in a post-order depth-first manner; after reaching the leaf node, the histogram of the current leaf node is sampled and data is generated, mainly for each bucket of the histogram, random sampling is performed between the upper and lower bounds of the bucket, and the number of samplings is the number of data in the bucket. After the sampling is completed, random noise is added to the sampling result, and the generated new data is realized according to the formula f(X)=(LH)(R1*X+R2), where L and H are the lower and upper bounds of the bucket respectively, R1 and R2 are both random values ​​between [-1,1], and X is the independent variable, that is, the original data. Then, the sampling result is randomly shuffled in units of data, and then the data is returned to the parent node; the parent node needs to be processed differently according to its type. If the parent node is a sum node, the data of the two child nodes are spliced ​​in rows; if the parent node is a product node, the data of the two child nodes are spliced ​​in columns; then, the entire sum-product network is traversed in the above manner until the root node is returned, and the sampling of the entire sum-product network is completed and data is generated.

[0096] After the data is generated, a second sum-product network is constructed according to the method in S10.

[0097] In addition, the data described in the present invention are multiple types of data. When it is numerical data, the above-mentioned noise addition formula is used to add noise to generate new data. When it is other types of data, a suitable method is used to generate new data. For example, when it is categorical data, a method of replacing the category is used as the generated new data. When it is string data, encrypted data is used as the generated new data.

[0098] Step S30: Obtain a first query of the workload, obtain a query range through query parsing, estimate the selectivity of each node in the first sum-product network based on the query range, and calculate the cardinality of the first query.

[0099] In the embodiment of the present invention, after obtaining the first query transmitted by the workload, the query is parsed by the parser to obtain the table to be queried by the query target, the columns to be queried in the table, and the query range in each column. After obtaining the query range, the selectivity of each node is estimated in the first sum-product network through the query range, and the first query cardinality is finally calculated. The selectivity of each node can represent the proportion of data selected by the query in the data domain where the node is located, which is convenient for users to further understand the specific distribution of data.

[0100] The first query is an initial query obtained from user input.

[0101] Further, the selecting rate of each node is estimated in the first sum-product network based on the query range, and the cardinality of the first query is calculated, which specifically includes:

[0102] Based on the query parsing result, by traversing the first sum-product network, the child node corresponding to the column to be queried is obtained, and the selectivity of the query under the condition is estimated in the child node according to the query condition, and returned to the parent node;

[0103] The selectivity is processed according to the parent node type. If the parent node is a sum node, the selectivity of the two child nodes is weighted by their respective row numbers and then summed and returned to the parent node; if the parent node is a product node, the selectivity of the two child nodes is directly multiplied and returned to the parent node;

[0104] The selectivity of each node is calculated until the calculation result is returned to the root node. The selectivity of the root node is multiplied by the total number of rows to obtain the cardinality estimate of the query, and the cardinality of the query is saved.

[0105] Specifically, Figure 4 As shown, for each query of the workload, query parsing can be used to determine which columns need to be queried and the corresponding query range; using the result of query parsing, by traversing the first sum-product network constructed by the original data, the child node corresponding to the column to be queried is found, and then the selectivity of the query under the condition is estimated in the histogram of the child node according to the query condition, and returned to the parent node; if the parent node is a sum node, the selectivity of the two child nodes is weighted by their respective number of rows and then summed and returned to the parent node; if the parent node is a product node, the selectivity of the two child nodes is directly multiplied and returned to the parent node; the above parent node selectivity calculation method is repeated until the root node, and the obtained selectivity is multiplied by the total number of rows to obtain the cardinality estimate of the query, which is saved.

[0106] In addition, the query parsing mentioned above is to parse the query string written in SQL language through a parser to obtain the scope of the query, and the parser is an essential function of the database, wherein the parser can be selected from various types of parsers such as the Postgresql parser.

[0107] The query process in S30 does not conflict with the process of collecting and generating new data in S20, and they can be coordinated and performed synchronously.

[0108] Step S40: based on the number of query results, node selection rate and cardinality obtained from the first query, query the new data to solve the scope of the second query, construct a benchmark test set based on the new data and the second query, estimate the selection rate of each node in the second sum-product network based on the second query scope, and calculate the cardinality of the second query.

[0109] In an embodiment of the present invention, a second query is performed on the new data by taking the number of query results of the second query obtained, the corresponding product node selectivity and the cardinality as the same as those of the first query as a condition. The scope of the second query is solved, and the selectivity of the second sum-product network is estimated and the cardinality is calculated based on the scope of the second query. By using the sum-product network to estimate the cardinality of the query, and then using the cardinality to solve the query range in the newly generated database, the structure of the original query is retained, and the corresponding query is generated by the collaboratively generated database, and the generated query meets the original cardinality.

[0110] The second query is a new query generated corresponding to the obtained new data.

[0111] Further, the query result quantity, node selection rate and cardinality obtained based on the first query are queried in the second sum-product network for new data to solve the scope of the second query, specifically including:

[0112] The query scope of the first query is removed, the query structure and cardinality of the first query are retained, and the scope of the second query is solved in the second sum-product network based on the number and cardinality of the first query results.

[0113] The query result quantity, node selection rate and cardinality obtained based on the first query, querying the new data in the second sum-product network to solve the scope of the second query specifically includes:

[0114] The second query queries the newly generated data, requiring that the selectivity of the column obtained by the second query is the same as the selectivity of the same column in the first query, and the cardinality obtained by the second query is the same as the cardinality obtained by the first query;

[0115] If the number of results obtained by the selected second query range is small, then the query range is increased;

[0116] If the number of results obtained by the selected second query range is large, narrow the query range;

[0117] When the number of results, column selection rate, and cardinality obtained by the second query are equal to the query results of the first query, the query range is solved and the query range at this time is used as the query range of the second query;

[0118] Based on the query range of the second query, the selectivity of each node in the second sum-product network is estimated, and the cardinality of the second query is calculated.

[0119] In addition, by generating new data and new queries from the original data and original query range of the present invention, users can build their own benchmark test sets and use the benchmark test sets to test various database products. At the same time, the data and queries contained in the benchmark test sets can be completely separated from the original data and queries, that is, the original data and queries cannot be traced back, and are separated from the sensitivity of the data and can be disclosed arbitrarily without leaking the user's sensitive information.

[0120] Exemplarily, after obtaining the benchmark test set, the data of the benchmark test set is inserted into the database to be tested, and then the query of the benchmark test set is executed on the database to be tested, and the execution situation is counted to obtain the test results, i.e., performance indicators, such as execution overhead, execution time, execution delay, throughput, etc., thereby reflecting the performance comparison of various database products under the business load of the user, i.e., daily operation; further, before each database manufacturer sells its database products to users, it can first use the user's benchmark test set for testing to prove that its database products can meet certain standards; specifically, when a company wants to upgrade its existing database in order to improve the current performance, there are several existing database products to choose from, then the company's benchmark data set can be distributed to various manufacturers, and a test report must be obtained using the benchmark test set under specified conditions. The company can directly compare the test reports to select a better database product, and the new data and the second query provided by the company will not leak the company's sensitive data, and can achieve comparison of database products, which greatly facilitates the company's use.

[0121] Further, according to Figure 2 The above steps S10-S40 of the present invention are further described as a whole, and the specific description is as follows:

[0122] The present invention constructs a sum-product network S according to an original database D, then performs noise sampling on the data in the sum-product network S to obtain a database D' constructed with new data, and uses the new database D' to construct a new sum-product network S'; after obtaining the workload, a sum-product network with selectivity and cardinality is obtained by parsing and estimating the cardinality in the sum-product network S, that is, a binary tree; after obtaining the new data, the scope of the new query is solved, and based on the scope of the new query, a sum-product network with selectivity and cardinality is constructed in the sum-product network S'.

[0123] Step S50: Generate a query heat map based on the query results and cardinality estimates obtained by the first sum-product network and the second sum-product network.

[0124] In this embodiment, the query selectivity and cardinality in the first sum-product network and the second sum-product network obtained in the above steps S30 and S40 can generate a query heat map accordingly. In this way, the query heat map generated by the sum-product network can be visually compared to verify the correctness of the generated data and query, that is, to verify that the generated data and query have similar characteristics to the original data and query.

[0125] Furthermore, the query results and cardinality estimation obtained based on the first sum-product network and the second sum-product network are used to generate a query heat map, which specifically includes:

[0126] The depth of the node color is mapped to the size of the selection rate. The node with a larger selection rate has a darker color, and vice versa. The entire first sum-product network and the second sum-product network are visualized by drawing to form a heat map of the query.

[0127] Specifically, as follows Figure 6 As shown, in steps S30 and S40, using the sum-product network for cardinality estimation will leave a query selection rate at each node. The selection rate of each node can represent the proportion of data selected by the query in the data domain where the node is located; the depth of the node color is mapped to the size of the selection rate, the larger the selection rate, the darker the color of the node, and vice versa. Based on this, the entire sum-product network can be visualized by drawing, that is, a heat map of the query is formed. By comparing the query heat map, it can be verified whether the generated new data and the new query range have similar characteristics to the original data and the query range. When the similarity characteristics are relatively poor, the row threshold, correlation coefficient and other parameters in the present invention are adjusted accordingly, so as to regenerate a benchmark test set with greater similarity.

[0128] In addition, if Figure 7 As shown, in the present invention as a whole, users can use the generated benchmark test set to compare the performance differences of various database products, and users do not need to worry about leaking sensitive data, and can test database products with data and queries that meet their own business characteristics. Before users replace database products, they can use the benchmark test set to verify whether the database product meets the user's needs, which greatly provides convenience for users.

[0129] In summary, the present embodiment provides a method, device, and medium for generating a database benchmark test set based on synchronous generation of data and queries, the method comprising: constructing a first sum-product network according to a database, the constructed sum-product network logically forming a binary tree; sampling the constructed first sum-product network and generating new data, and constructing a second sum-product network based on the new data; obtaining a first query of the workload, obtaining a query range through query parsing, estimating the selectivity of each node in the first sum-product network based on the query range, and calculating the cardinality of the first query; querying the new data based on the number of query results, node selectivity, and cardinality obtained from the first query, solving the scope of the second query, constructing a benchmark test set from the new data and the second query, estimating the selectivity of each node in the second sum-product network based on the second query range, and calculating the cardinality of the second query; generating a query heat map based on the query results and cardinality estimates obtained from the first sum-product network and the second sum-product network. The embodiment of the present invention constructs a sum-product network through a database, which can well capture the data distribution of the original database; performs data sampling on the sum-product network, replaces the original data and adds random data noise disturbance, and solves the query range in the newly generated database through the cardinality corresponding to the original data, so that the structure of the original query is retained, and the corresponding query is generated by the collaboratively generated database, and the generated query conforms to the original cardinality, so that the user can use the existing data and query to generate a user-exclusive benchmark test set. The data and queries contained in the benchmark test set can be completely separated from the original data and queries, and can be arbitrarily disclosed without leaking the user's sensitive information, and can reflect the user's own business logic for specific scenarios, and at the same time can reflect the data distribution of the user database; in addition, the present invention also uses the sum-product network to generate a query heat map for visual comparison to verify the correctness of the generated data and queries, thereby improving the convenience of user use.

[0130] Exemplary Devices

[0131] like Figure 8 As shown in, based on the above-mentioned database benchmark test set generation method based on data and query synchronous generation, an embodiment of the present invention provides a database benchmark test set generation device based on data and query synchronous generation, the device comprising:

[0132] A network construction module 810 is used to construct a sum-product network according to the database, and the constructed sum-product network logically forms a binary tree;

[0133] A data acquisition module 820, configured to sample the constructed first sum-product network and generate new data;

[0134] The cardinality estimation and new query range acquisition module 830 acquires a first query of the workload, obtains a query range through query parsing, estimates the selectivity of each node in the first sum-product network based on the query range, and calculates the cardinality of the first query, queries new data based on the number of query results, node selectivity, and cardinality obtained from the first query, solves the range of the second query, constructs a benchmark test set based on the new data and the second query, estimates the selectivity of each node in the second sum-product network based on the second query range, and calculates the cardinality of the second query;

[0135] The heat map generation module 840 is used to generate a query heat map based on the query results and cardinality estimates obtained by the first sum-product network and the second sum-product network, as described above.

[0136] Based on the above embodiment, the present invention further provides a terminal device. The terminal device includes a memory, a processor, and a database benchmark test set generation program based on data and query synchronous generation stored in the memory and executable on the processor, and when the processor executes the database benchmark test set generation program based on data and query synchronous generation, the steps of the database benchmark test set generation method based on data and query synchronous generation are implemented.

[0137] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0138] The present invention captures the data distribution of the database by constructing a first sum-product network based on a database given by a user, and then generates a large amount of new data that conforms to the distribution of the original database by sampling the sum-product network; at the same time, the workload given by the user, i.e., a series of queries, is estimated in the first sum-product network, and the obtained cardinality is used to solve the range of the new query in the generated data, so as to generate a new query, and a specific benchmark test set is generated by the new data and the new query. The present invention enables the query and data of the test set to be generated completely according to the query and data characteristics of the user, and the generated data and query will replace the original original data, and random noise will be added, so that the generated test set can not only well reflect the user's business logic and data distribution, but also be separated from the sensitivity of the original data. The present invention is plug-and-play, and does not require the user to perform additional settings, so that each user can generate his own benchmark test data set through the present invention. At the same time, the present invention can visualize the sum-product network and any query, forming a heat map of the query on the data, so that the user can intuitively feel the difference between the execution of the generated data and query and the original execution, thereby ensuring the correctness of the generated data and query.

[0139] In summary, the present invention discloses a method, device, and medium for generating a database benchmark test set based on synchronous generation of data and queries. The embodiment of the present invention captures the distribution of original data by constructing a sum-product network for the data in the database, generates new data by adding noise to the original data, and uses the sum-product network to estimate the cardinality of the original query, and then uses the cardinality to solve the query range in the newly generated database, so that the structure of the original query is retained, and the corresponding query is generated by the collaboratively generated database, and the generated query conforms to the original cardinality, thereby achieving the effect of generating more queries based on the existing query template, and the generated new data and new queries can construct a specific benchmark test set, which can reflect the user's own business logic for a specific scenario and the data distribution of the user database. In addition, the present invention uses the sum-product network to generate a query heat map for visual comparison, which can be used to verify the correctness of the generated data and query, and compare whether the generated data and query have similar characteristics with the original data and query, providing users with a guarantee of whether the data is reliable.

[0140] It should be understood that the application of the present invention is not limited to the above examples. For those skilled in the art, improvements or changes can be made based on the above description. All these improvements and changes belong to the protection scope of the claims attached to the present invention.

[0141] Furthermore, the following changes fall within the protection scope of the claims attached to the present invention, including:

[0142] The subnodes of the sum-product network are modeled by any other model; the row partitioning of the sum-product network is constructed by any other clustering algorithm or partitioning method; the column partitioning of the sum-product network is constructed by any other standard except the correlation coefficient to measure the correlation;

[0143] The process of constructing and integrating networks uses other rules;

[0144] Use other sampling algorithms for sampling sum-product networks;

[0145] Collaborate data generation and query generation through other algorithms;

[0146] Generate query heatmaps through other structures and algorithms;

[0147] Other algorithms are used to generate benchmark test sets that are similar to the user's business logic and are independent of the user's data.

[0148] The above-mentioned improvements and changes belong to the protection scope of the claims attached to the present invention, and the changes and improvements of the present invention are not limited to the above-mentioned distances. For ordinary technicians in this field, other improvements or changes can be made according to the above description. All these improvements and changes should belong to the protection scope of the claims attached to the present invention.

Claims

1. A database benchmark test set generation method based on synchronous generation of data and queries, It is characterized in that The method comprises: A first sum-product network is constructed according to the database, and the constructed sum-product network logically forms a binary tree; Sampling the constructed first sum-product network and generating new data, and constructing a second sum-product network based on the new data; Obtaining a first query of the workload, obtaining a query range through query parsing, estimating a selectivity of each node in a first sum-product network based on the query range, and calculating a cardinality of the first query; Based on the number of query results, node selection rate and cardinality obtained from the first query, query the new data to solve the range of the second query, build a benchmark test set based on the new data and the second query, estimate the selection rate of each node in the second sum-product network based on the second query range, and calculate the cardinality of the second query; A query heat map is generated based on the query results and cardinality estimates obtained from the first sum-product network and the second sum-product network.

2. The method for generating a database benchmark test set based on synchronous generation of data and queries as claimed in claim 1, It is characterized in that The step of constructing the first sum-product network according to the database specifically includes: The data table in the current database is divided and constructed into nodes through row division and column division to obtain the first sum-product network.

3. The method for generating a database benchmark test set based on synchronous generation of data and queries as claimed in claim 1, It is characterized in that The sampling of the constructed first sum-product network and generation of new data, and constructing a second sum-product network based on the new data specifically includes: The data of the leaf nodes in the binary tree are processed by noise and randomly sampled, and the data are concatenated in rows or columns according to the parent node type of the leaf nodes until all the data are returned to the root node and a new data table is formed. Construct a new sum-product network for the new data table.

4. The method for generating a database benchmark test set based on synchronous generation of data and queries as claimed in claim 1, It is characterized in that The step of estimating the selection rate of each node in the first sum-product network based on the query range and calculating the cardinality of the first query specifically includes: Based on the query parsing result, by traversing the first sum-product network, the child node corresponding to the column to be queried is obtained, and the selectivity of the query under the query condition is estimated in the child node according to the query condition, and returned to the parent node; The selectivity is processed according to the parent node type. If the parent node is a sum node, the selectivity of the two child nodes is weighted by their respective row numbers and then summed and returned to the parent node; if the parent node is a product node, the selectivity of the two child nodes is directly multiplied and returned to the parent node; The selectivity of each node is calculated until the calculation result is returned to the root node. The selectivity of the root node is multiplied by the total number of rows to obtain an estimate of the cardinality of the query, and the cardinality of the first query is obtained by saving it.

5. The method for generating a database benchmark test set based on synchronous generation of data and queries as claimed in claim 1, It is characterized in that The query result quantity, node selection rate and cardinality obtained based on the first query, querying the new data in the second sum-product network to solve the scope of the second query specifically includes: The query scope of the first query is removed, the query structure and cardinality of the first query are retained, and the scope of the second query is solved in the second sum-product network based on the number and cardinality of the first query results.

6. The method for generating a database benchmark test set based on synchronous generation of data and queries as claimed in claim 5, It is characterized in that The query result quantity, node selection rate and cardinality obtained based on the first query, querying the new data in the second sum-product network to solve the scope of the second query specifically includes: The second query queries the newly generated data, requiring that the selectivity of the column obtained by the second query is the same as the selectivity of the same column in the first query, and the cardinality obtained by the second query is the same as the cardinality obtained by the first query; If the number of results obtained by the selected second query range is small, then the query range is increased; If the number of results obtained by the selected second query range is large, narrow the query range; When the number of results, column selection rate, and cardinality obtained by the second query are equal to the query results of the first query, the query range is solved and the query range at this time is used as the query range of the second query; Based on the query range of the second query, the selectivity of each node in the second sum-product network is estimated, and the cardinality of the second query is calculated.

7. The method for generating a database benchmark test set based on synchronous generation of data and queries as claimed in claim 1, It is characterized in that The query results and cardinality estimates obtained based on the first sum-product network and the second sum-product network are used to generate a query heat map, specifically comprising: The depth of the node color is mapped to the size of the selection rate. The node with a larger selection rate has a darker color, and vice versa. The entire first sum-product network and the second sum-product network are visualized by drawing to form a heat map of the query.

8. A database benchmark test set generation device based on synchronous generation of data and queries, It is characterized in that The device comprises: A network construction module is used to construct a sum-product network according to the database. The constructed sum-product network logically forms a binary tree. A data acquisition module, used for sampling the constructed first sum-product network and generating new data; A cardinality estimation and new query range acquisition module obtains a first query of the workload, obtains a query range through query parsing, estimates the selectivity of each node in a first sum-product network based on the query range, and calculates the cardinality of the first query, queries new data based on the number of query results, node selectivity, and cardinality obtained from the first query, solves the range of a second query, constructs a benchmark test set based on the new data and the second query, estimates the selectivity of each node in a second sum-product network based on the second query range, and calculates the cardinality of the second query; A heat map generation module is used to generate a query heat map based on the query results and cardinality estimates obtained by the first sum-product network and the second sum-product network.

9. A terminal device, It is characterized in that The terminal device includes a memory, a processor, and a database benchmark test set generation program based on data and query synchronous generation, which is stored in the memory and can be run on the processor. When the processor executes the database benchmark test set generation program based on data and query synchronous generation, it implements the steps of the database benchmark test set generation method based on data and query synchronous generation as described in any one of claims 1 to 7.

10. A computer-readable storage medium, It is characterized in that A database benchmark test set generation program based on data and query synchronization generation is stored thereon. When the database benchmark test set generation program based on data and query synchronization generation is executed by a processor, the steps of the database benchmark test set generation method based on data and query synchronization generation are implemented as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Performance benchmark test system and method for big data stream processing framework

    CN108683560A

  • Metric space index tree construction method and device, computer equipment and storage medium

    CN113590889A