Vectorized database query method and device

Through the vectorized database query method, the null identifier and relational expression of the target column data are used to perform logical operations, which solves the problem of inefficient processing of NULL values ​​and overflow values ​​in the database, and achieves performance acceleration and efficiency improvement.

CN113553345BActive Publication Date: 2024-09-03BUSINESS-INTELLIGENCE OF ORIENTAL NATIONS CORP LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202110815471.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-19
Publication Date
2024-09-03
Estimated Expiration
2041-07-19

AI Technical Summary

Technical Problem

In the prior art, the processing efficiency of NULL values ​​and overflows in the database is low, which leads to CPU branch judgment errors and clock cycle penalties, affecting the performance of query processing.

Method used

Through the vectorized database query method, based on the empty identifier and relational expression of the target column data, logical AND operations are performed to obtain the query results, and overflow exception prompts are output when necessary, reducing branch judgments and improving processing efficiency.

Benefits of technology

It achieves performance acceleration for database queries, reduces the number of branch judgments, and improves the efficiency of processing NULL values ​​and overflow values.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113553345B
    Figure CN113553345B
Patent Text Reader

Abstract

The present invention provides a method and device for querying a vectorized database, which receives a query statement input by a user; in response to the query statement, determines target column data and a relational expression based on the query statement; obtains the empty flag of each row in the query result based on the empty flag of each row in the target column data; obtains the query result based on the empty flag of each row in the query result, the target column data, and the relational expression. The method and device for querying a vectorized database provided by the present invention obtains the empty flag of each row in the query result based on the empty flag of each row in the target column data, performs logical operations on the empty flags of each row in the query result and the target column data, executes the relational expression in the query statement and obtains the query result, which can reduce branch judgments to achieve performance acceleration.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a query method and device for a vectorized database. Background Art

[0002] Nowadays, more and more databases and big data analysis are beginning to adopt column storage structures, because column storage can not only reduce cache misses, but also use the vectorization properties of the processor to achieve performance acceleration.

[0003] However, for NULL values ​​and overflows in the database, the existing CPU uses branch judgment to process data. Once a branch judgment error occurs, a clock cycle penalty (loss) will be generated. In addition, the existence of a branch judgment loop leads to inefficient processing of NULL values ​​and overflows. Summary of the invention

[0004] The present invention provides a vectorized database query method and device, which are used to solve the defect of low query processing efficiency in the prior art and achieve performance acceleration.

[0005] The present invention provides a method for querying a vectorized database, comprising:

[0006] Based on the query statement, determine the target column data and relational expressions;

[0007] Based on the empty flag of each row in the target column data, obtaining the empty flag of each row in the query result;

[0008] The query result is obtained based on the empty flag of each row in the query result, the target column data and the relational expression.

[0009] According to the vectorized database query method provided by the present invention, after obtaining the query result based on the empty flag of each row in the query result, the target column data and the relational expression, the method further includes:

[0010] When overflow occurs in any row of the query result, an overflow exception prompt is output.

[0011] According to a vectorized database query method provided by the present invention, the query result is obtained based on the empty flag of each row in the query result, the target column data and the relational expression, including:

[0012] For each target row, a logical AND operation is performed on the empty flag of the target row in the query result and the element of the target row in each target column data, and the empty value processing result of the target row is obtained;

[0013] Based on the null value processing result of the target row and the relational expression, an element of the target row in the query result is determined.

[0014] According to a vectorized database query method provided by the present invention, the step of obtaining the empty flag of each row in the query result based on the empty flag of each row in the target column data includes:

[0015] For each target row, obtaining a null flag of the target row in each target column data;

[0016] A logical AND operation is performed based on the empty flag of the target row in the target column data to obtain the empty flag of each row in the query result.

[0017] According to a vectorized database query method provided by the present invention, after determining the element of the target row in the query result based on the null value processing result of the target row and the relational expression, the method further includes:

[0018] Overflow detection is performed on elements of the target row in the query result to determine whether overflow exists in the target row of the query result.

[0019] According to the vectorized database query method provided by the present invention, the overflow exception prompt includes: the row number of each row in the query result where the overflow occurs.

[0020] The present invention also provides a query device for a vectorized database, comprising:

[0021] A receiving module, used for receiving a query statement input by a user; a statement parsing module, used for responding to the query statement and determining target column data and a relational expression based on the query statement;

[0022] A null value detection module, used to obtain a null flag of each row in the query result based on the null flag of each row in the target column data;

[0023] The data processing module is used to obtain the query result based on the empty mark of each row in the query result, the target column data and the relational expression.

[0024] According to the present invention, a query device for a vectorized database further includes:

[0025] The overflow detection module is used to output an overflow exception prompt when any row of the query result has overflow.

[0026] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the above-mentioned vectorized database query methods are implemented.

[0027] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the query method of the vectorized database as described above are implemented.

[0028] The query method and device for a vectorized database provided by the present invention obtain the empty flags of each row in the query result based on the empty flags of each row in the target column data, and after performing logical operations on the empty flags of each row in the query result and the target column data, execute the relational expression in the query statement and obtain the query result, which can reduce branch judgments to achieve performance acceleration. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0030] Figure 1 It is a flowchart of the query method of the vectorized database provided by the present invention;

[0031] Figure 2 It is a structural schematic diagram of a query device for a vectorized database provided by the present invention;

[0032] Figure 3 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0033] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0034] Figure 1 FIG. 1 is a flow chart of the query method of the vectorized database provided by the present invention. Figure 1 As shown, the query method of the vectorized database provided by the embodiment of the present invention includes: step 101, receiving a query statement input by a user.

[0035] It should be noted that the execution subject of the query method of the vectorized database is the query device of the vectorized database, and the object of implementing the query method is the data stored in the database. Among them, according to the basic logical storage unit stored in the database, the database can be divided into two types: row storage database and column storage database. The embodiment of the present invention does not specifically limit the type of database.

[0036] For example, it may be a row storage database that stores data based on row data as a basic logical storage unit, such as a traditional relational database such as Oracle, DB2, MySQL, SQL SERVER, etc.

[0037] Preferably, the database is a column storage database that stores data in logical storage units based on column data, such as emerging distributed databases such as Hbase, HP Vertica, and EMC Greenplum.

[0038] It should be noted that a query statement refers to a data processing method, and data that meets the conditions is obtained in the database according to the query conditions specified in the query statement. Different types of databases correspond to different types of data processing, and the embodiment of the present invention does not specifically limit the types of query statements.

[0039] For example, the query statement may be an online analytical processing (OLAP) statement, which is used to perform some basic and daily transaction processing on a row-based storage database, such as adding, deleting, modifying, and checking database records.

[0040] Specifically, the user inputs a query statement to a query device for a vectorized database or an electronic device provided with a query device for a vectorized database according to actual analysis requirements.

[0041] Preferably, the query statement is an online analytical processing (OLAP) for performing computational analysis on a row-based storage database.

[0042] Step 102: In response to a query statement, determine target column data and a relational expression based on the query statement.

[0043] It should be noted that the query method of the vectorized database is applicable to the scenario where an OLAP-type query statement may need to access millions or even billions of data rows, and the query statement often only cares about a few data columns.

[0044] The target column data refers to at least two data columns to be calculated and analyzed in the query statement.

[0045] For example, to query the top 20 products with the highest sales this year, this query only cares about three data columns: date, item, and sales amount. Other data columns of the product, such as product URL, product description, product store, etc., are meaningless to this query.

[0046] In this application scenario, the column-based database only needs to read the data columns storing "time, product, and sales" to analyze a large amount of data according to OLAP-type query statements. In order to obtain the three columns of "time, product, and sales", the row-based database needs to read all the data columns in the database and then process them, which has low reading efficiency. Therefore, when the column-based database executes OLAP-type query statements, it still needs to process NULL values ​​and overflow values.

[0047] Specifically, the query device of the vectorized database parses the received query statement to obtain the data and data processing relationship expressions under the fields corresponding to the query statement. The embodiment of the present invention does not specifically limit the storage method of the data under the corresponding fields.

[0048] Preferably, all data under the corresponding fields are stored continuously in the storage medium in the order of columns. Accordingly, through one query statement, the columns involved in the query and all data stored in the columns can be read at one time.

[0049] The relational expression may be a four-arithmetic operation relationship of addition, subtraction, multiplication and division between multiple target column data, or a compound operation relationship, which is not specifically limited in the embodiment of the present invention.

[0050] Step 103: Based on the empty flag of each row in the target column data, obtain the empty flag of each row in the query result.

[0051] It should be noted that NULL in the database means that the data value of the element is NULL, and the calculation result of NULL and any element is NULL.

[0052] The null flag is a representation independent of the data itself, used to indicate whether the value of the data itself is NULL.

[0053] The query result refers to the result obtained after the relational expression parsed in step 102 is calculated on the multiple target column data.

[0054] Specifically, after the object and method of data processing are determined in step 102, for any row in the target column data, the empty flag of each element of the target column data in the row is used to perform corresponding logical operations according to the NULL operation rules to obtain the empty flag of the query result of the row, so as to know whether the query result of the row is NULL.

[0055] For the empty flags of the remaining rows in the query result, a loop or iteration may be performed using the number of rows as a variable, and the empty flags of the query results for all rows may be obtained, which is not specifically limited in the embodiment of the present invention.

[0056] Step 104: Obtain query results based on the empty flags of each row in the query results, the target column data, and the relational expressions.

[0057] Specifically, after determining the empty flag of the query result in step 103, for any row in the target column data, the query device of the vectorized database performs logical operations on the empty flag of the query result of that row and each element of the target column data in that row, executes the relational expression parsed in step 102 on multiple logical operation results, and obtains the query result after data processing.

[0058] For the query results of the remaining rows, a loop or iteration may be performed with the number of rows as a variable, and query results on all rows may be obtained, which is not specifically limited in the embodiment of the present invention.

[0059] The following example illustrates a specific implementation of a method for setting up a vectorized database query.

[0060] For example, according to the common query statement "select c1+c2 from table", it means to add the data in the c1 column and the data in the c2 column row by row.

[0061] The traditional query processing flow is:

[0062]

[0063] Where N is the total number of data rows, c1 and c2 are two columns of data in the database, c1_isNull and c2_isNull are the null flags corresponding to c1 and c2 respectively, and result is the query result.

[0064] In the loop, an if judgment is performed for each row. Through the bitwise AND operation of c1_isNull and c2_isNull, if the operation result does not satisfy the condition that at least one of c1 and c2 is NULL, c1 and c2 are added.

[0065] Until the end of the loop, the number of rows processed is N, but 2N operations are performed, of which N are executing the if branch judgment, and the other N are executing the corresponding operations according to the branch judgment results.

[0066] The query processing flow provided by the embodiment of the present invention is as follows:

[0067]

[0068] Where N is the total number of data rows, c1 and c2 are two columns of data in the database, tmp_c1 and tmp_c2 are the null value processing results corresponding to c1 and c2 respectively, c1_isNull, c2_isNull and result_isNull are the null flags corresponding to c1, c2 and result respectively, and result is the query result.

[0069] In the loop, for each row, firstly obtain result_isNull through the bitwise AND operation of c1_isNull and c2_isNull to indicate whether result is null. The corresponding identification rules of c1_isNull, c2_isNull and result_isNull are: if the corresponding data is null, all are 0; if the corresponding data is not null, all are 1.

[0070] Perform a bitwise AND operation on the null flag (result_isNull) of the query result column of this row and the elements of c1 and c2 in this row respectively:

[0071] If result_isNull is not empty, result_isNull is all 1, and the logical operation results of c1 and c2, tmp_c1 and tmp_c2, are the data of c1 and c2 respectively. In this way, the query result result is the sum of tmp_c1 and tmp_c2, that is, the sum of c1 and c2.

[0072] If result_isNull is empty, result_isNull is all 0, and the logical operation results tmp_c1 and tmp_c2 with c1 and c2 are both 0. In this way, the query result result is the sum of tmp_c1 and tmp_c2, that is, 0+0, and its performance can be omitted.

[0073] By the end of the loop, the number of rows processed is N, corresponding to N operations performed, which is half the number of operations compared to the traditional query process.

[0074] The embodiment of the present invention obtains the empty flag of each row in the query result based on the empty flag of each row in the target column data, performs logical operations on the empty flag of each row in the query result and the target column data, executes the relational expression in the query statement and obtains the query result, which can reduce branch judgments to achieve performance acceleration.

[0075] On the basis of any of the above embodiments, after obtaining the query result based on the empty flags of each row in the query result, the target column data and the relational expression, it also includes: if there is an overflow in any row of the query result, an overflow exception prompt is output.

[0076] It should be noted that, for any row of the column storage database, after step 104, overflow detection is also performed on the query result.

[0077] Overflow means that the result of an arithmetic operation exceeds the maximum range that can be represented at present. This arithmetic overflow is unacceptable to the database and an exception needs to be thrown to notify the user.

[0078] Specifically, after obtaining the query result in step 104, for any row in the query result, the query device of the vectorized database executes an overflow detection algorithm to detect the query result of the row. The embodiment of the present invention does not specifically limit the overflow detection algorithm executed.

[0079] When it is detected that the value of the query result of the row overflows, an overflow exception prompt is output. The embodiment of the present invention does not specifically limit the form of the exception prompt.

[0080] For example, it may be displayed in the interface as text, or stored in the form of a table.

[0081] When it is detected that the query result value of the row has not overflowed, the query result of the row is directly output.

[0082] For the overflow detection of the query results of the remaining rows, a loop or iteration may be performed with the number of rows as a variable, and the overflow detection may be performed on the query results of all rows, which is not specifically limited in the embodiment of the present invention.

[0083] Preferably, for overflow detection of query results of remaining rows, the number of rows can be used as a variable, and after the null value processing is completed, a loop or iteration is performed following the null value processing, and overflow detection can be performed on query results of all rows.

[0084] The following example illustrates a specific implementation of a method for setting up a vectorized database query.

[0085] For example, according to the common query statement "select c1+c2 from table", it means to add the data in the c1 column and the data in the c2 column row by row.

[0086] The traditional query processing flow is:

[0087]

[0088]

[0089] Where N is the total number of data rows, c1 and c2 are two columns of data in the database, c1_isNull and c2_isNull are the null flags corresponding to c1 and c2 respectively, result is the query result, over_flow_calc is the overflow detection algorithm, and over_flow is the overflow flag.

[0090] In the loop, branch judgment is required for each row before the operation can be performed. After obtaining the query result of the row, overflow detection is performed. Then, according to the judgment of another branch, it is known whether the value of the query result overflows, and different operations are performed according to the judgment result.

[0091] Until the end of the loop, the number of rows processed is N. After two nested if branch judgments, it is equivalent to executing 4N operations.

[0092] The query processing flow provided by the embodiment of the present invention is as follows:

[0093]

[0094]

[0095] Where N is the total number of data rows, c1 and c2 are two columns of data in the database, tmp_c1 and tmp_c2 are the null value processing results corresponding to c1 and c2 respectively, c1_isNull, c2_isNull and result_isNull are the null flags corresponding to c1, c2 and result respectively, result is the query result, over_flow_calc is the overflow detection algorithm, over_flow_tmp is the overflow detection result, and over_flow is the overflow position flag.

[0096] In the loop, for each row, after obtaining the query result of the row, an overflow judgment is performed to obtain the overflow detection result. Among them, if the over_flow_calc() function returns 0, then over_flow_tmp is 0, indicating that there is no overflow and the query result of the row can be directly output. If the over_flow_calc() function returns 1, then over_flow_tmp is 1, indicating that there is an overflow and an exception needs to be thrown. Therefore, before the start of the loop, the default value of the over_flow[1] position is set to -1. If there is an overflow in the row, the value of this position will be modified to the corresponding number of rows. Finally, the updated value of the over_flow[1] position is compared with the default value -1. If the updated value of the over_flow[1] position is equal to the default value -1, no exception is thrown. If the updated value of the over_flow[1] position is not equal to the default value -1, an exception is thrown.

[0097] Until the end of the loop, the number of processed rows is N, and N+1 operations are performed accordingly. Among them, N operations obtain the query results and the corresponding overflow position identifiers, and the last operation is to perform a full value scan on the overflow position identifiers of all rows. Compared with the traditional query process, the number of operations is significantly reduced.

[0098] The embodiment of the present invention performs overflow detection based on the obtained query results and executes full value scanning and full value calculation, which can reduce branch judgment and integrate parallel calculation of null value detection and overflow detection to achieve performance acceleration.

[0099] On the basis of any of the above embodiments, based on the empty flag of each row in the query result, the target column data and the relational expression, the query result is obtained, including:

[0100] For each target row, the null flag of the target row in the query result is logically ANDed with the elements of the target row in each target column data, and the null value of the target row is processed as the result.

[0101] It should be noted that the target row refers to a row in the query result column vector or the target column data, wherein the query result column vector and the target column data have the same target row.

[0102] Specifically, for each target row in the column vector, the query device of the vectorized database performs a logical AND operation on the empty flag of the query result of the row and each target column data involved in the query statement to obtain the empty value processing result of each target column data in the row.

[0103] The null value processing result is used to indicate the result obtained by the corresponding null value processing on the element itself, and its purpose is to make all the elements in the row of all column vectors participating in the query processing to be converted to 0 if the query result of the row has a null value. If the query result of the row does not have a null value, the elements in the row of all column vectors participating in the query processing remain their values. The embodiment of the present invention does not specifically limit the null value processing process.

[0104] Preferably, the null value processing process is to perform a logical AND operation on the elements of the target row of the null flag target column data of the query result of the row. Wherein, if the null flags of any row of query results are all 0, it means that there are null values ​​in the query result, and there are null values ​​in the elements of the corresponding rows in one or several column vectors participating in the query processing. If the null flags of any row of query results are all 1, it means that there are no null values ​​in the query result, and there are no null values ​​in the elements of the corresponding rows in all column vectors participating in the query processing.

[0105] Based on the null value processing result of the target row and the relational expression, the element of the target row in the query result is determined.

[0106] Specifically, the query device of the vectorized database executes the relational expression parsed in step 102 according to the null value processing result of the target row to obtain the query result corresponding to the target row.

[0107] For query results of other rows, the above processing steps can be executed in a loop or iteration with the number of rows as a variable, which will not be described in detail in this embodiment.

[0108] The following example illustrates a specific implementation method for setting up vectorized database null value processing.

[0109] For example, c1=null and c2=3 of a target row. Since there is a null value between them, the query result obtained by the query statement select c1+c2 from table is also a null value, that is, its null flag result_isNull is all 0. Then perform a logical AND operation on result_isNull and c1 and c2 respectively. For result_isNull&c1, that is, 00000000&null=00000000, and for result_isNull&c2, that is, 00000000&00000011=00000000. After such processing, the null value processing results of c1 and c2, that is, tmp_c1 and tmp_c2, are both 0. Therefore, c1+c2 with a null value is converted into tmp_c1 and tmp_c2=0+0=0, and its performance is greatly reduced.

[0110] For a target row, c1=1, c2=3. Since there is no null value between them, the query result obtained by the query statement selectc1+c2 from table is not a null value, that is, its null flag result_isNull is all 1. Then perform a logical AND operation on result_isNull, c1 and c2 respectively. For result_isNull&c1, that is, 11111111&00000001=00000001, and for result_isNull&c2, that is, 11111111&00000011=00000011. After such processing, the null value processing results of c1 and c2, that is, tmp_c1 and tmp_c2, are still 1 and 3 respectively. Therefore, after processing, tmp_c1+tmp_c2=c1+c2=4.

[0111] The embodiment of the present invention performs logical operations based on the null flags of each row in the query result and the target column data to obtain a null value processing result. By executing the relational expression in the query statement on the null value processing result and obtaining the query result, branch judgments can be reduced to achieve performance acceleration.

[0112] Based on any of the above embodiments, obtaining the empty flag of each row in the query result based on the empty flag of each row in the target column data includes:

[0113] For each target row, get the empty flag of the target row in the target column data.

[0114] Specifically, for each target column data involved in the query statement, in each row, the query device of the vectorized database first obtains the empty flag corresponding to the element based on the element of the target column data in the target row to indicate whether the element of the target column data in the target row is empty.

[0115] Perform a logical AND operation based on the empty flag of the target row in the target column data to obtain the empty flag of each row in the query result.

[0116] Specifically, the query device of the vectorized database determines whether the elements of the query result in the target row are empty based on the empty flags of all target column data involved in the query statement in the target row. The embodiment of the present invention does not specifically limit the determination process.

[0117] Preferably, the query device of the vectorized database performs a logical AND operation on the empty flags of all target column data involved in the query statement in the target row to obtain the empty flag of the query result corresponding to the query statement in the target row to indicate whether the elements of the query result in the target row are empty.

[0118] The following example illustrates a specific implementation method of setting up a vectorized database to determine whether a query result is empty.

[0119] For example, for a target row, c1=null and c2=3, the traditional judgment process is to first obtain the query result result=c1+c2=null according to the query statement select c1+c2 from table, and then judge the query result to find that the result is null, that is, result_isNull is all 0.

[0120] The determination process provided by the embodiment of the present invention is: first determine whether c1 and c2 are null respectively, so as to obtain c1_isNull is all 0 and c2_isNull is all 1. According to the null flags of c1 and c2, a logical AND operation is performed, that is, if there is at least one null flag that is all 0, then the query result must have a null value. The process is:

[0121] result_isNull=c1_isNull&c2_isNull=00000000&11111111=0000000. When result_isNull is all 0, it means that there is a null value in the query result.

[0122] If both c1 and c2 are not null, then c1_isNull and c2_isNull are all 1.

[0123] result_isNull=c1_isNull&c2_isNull=111111111&11111111=11111111. When result_isNull is all 1, it means that there is no null value in the query result.

[0124] The embodiment of the present invention obtains the null flag of the query result based on the null flag of the target row in each target column data, which can reduce invalid operations in the presence of null values ​​to achieve performance acceleration.

[0125] Based on any of the above embodiments, after determining the elements of the target row in the query result based on the null value processing result and the relational expression of the target row, it also includes: performing overflow detection on the elements of the target row in the query result to determine whether there is overflow in the target row of the query result.

[0126] Specifically, for each target row, after obtaining the query result of the row, the query device of the vectorized database executes an overflow detection algorithm on the query result of the row to determine whether the value of the query result of the row overflows. The embodiment of the present invention does not specifically limit the overflow detection algorithm.

[0127] Preferably, after the query device of the vectorized database executes the overflow detection algorithm on the query result of the row, if the return value of the overflow detection function is 0, it means there is no overflow, and the query result of the row can be directly output. If the return value of the overflow detection function is 1, it means there is overflow and an exception needs to be thrown.

[0128] For the overflow detection of the query results of the remaining rows, a loop or iteration may be performed with the number of rows as a variable, and the overflow detection may be performed on the query results of all rows, which is not specifically limited in the embodiment of the present invention.

[0129] Preferably, for overflow detection of query results of remaining rows, the number of rows can be used as a variable, and after the null value processing is completed, a loop or iteration is performed following the null value processing, and overflow detection can be performed on query results of all rows.

[0130] The embodiment of the present invention performs overflow detection based on the obtained query results and executes full value scanning and full value calculation, which can reduce branch judgment and integrate parallel calculation of null value detection and overflow detection to achieve performance acceleration.

[0131] Based on any of the above embodiments, the overflow exception prompt includes: the row numbers of each row in the query result where the overflow occurs.

[0132] It should be noted that the overflow exception prompt refers to a prompt used to indicate to the user that an overflow exception exists when overflow detection is performed on the query result. The embodiment of the present invention does not specifically limit the prompt method.

[0133] For example, the number of overflowed rows can be stored in a table output, or a prompt can be given in the form of a text box.

[0134] Preferably, the overflow exception prompt is to throw an exception using the throw mechanism in the function body.

[0135] Specifically, for each target row, when it is known that there is an overflow in the query result of the row, the row number of the target row is output as the content of the exception prompt so that the user knows which row in the query result has a numerical overflow. The embodiment of the present invention does not specifically limit the process of outputting the exception prompt.

[0136] Preferably, the judgment condition about the overflow position identifier is pre-set before the start of the loop, and the corresponding overflow position identifier is updated according to the overflow detection result. When the updated overflow position identifier does not meet the preset judgment condition, an exception is thrown in the function body.

[0137] The following example illustrates a specific implementation method for setting a vectorized database overflow processing flow.

[0138] For example, the overflow[1] position is pre-set to a default value of -1 before the loop starts.

[0139] In the for loop with the number of rows as a variable, after obtaining the query results, perform the following operations:

[0140] over_flow_tmp=over_flow_calc();

[0141] over_flow[over_flow_tmp]=i;

[0142] In the loop, if the query result of the row overflows, the return value of the overflow detection function over_flow_calc() is 1. Correspondingly, the position marker of over_flow[over_flow_tmp] is over_flow[1], and then the value corresponding to this position marker is modified to make its value the corresponding row number.

[0143] If there is no overflow in the query result of this row, the return value of the overflow detection function over_flow_calc() is 0. Correspondingly, the location marker of over_flow[over_flow_tmp] is over_flow[0], and then the value corresponding to this location marker is modified so that its value is the corresponding row number.

[0144] The updated value corresponding to the position marker is compared with the initial condition over_flow[1]=-1 set before the loop.

[0145] If the updated value of overflow[1] is equal to the default value -1, no exception is thrown. If the updated value of overflow[1] is not equal to the default value -1, an exception is thrown.

[0146] If the position flag is over_flow[0], it is not processed.

[0147] The following example illustrates a specific implementation method for setting another vectorized database overflow processing flow.

[0148] According to the query statement select c1 from table, it can be known that the query result is all elements in the c1 column. At this time, since no operations between multiple column vectors are involved, the above overflow processing flow can be directly executed on the elements of each row in the c1 column, which is not described in detail in the embodiment of the present invention.

[0149] In the embodiment of the present invention, when the query result obtained is overflow, the corresponding row number is output as the exception prompt content, so that the user can know the location of the overflow, reduce branch judgment, and integrate the parallel calculation of null value detection and overflow detection to achieve performance acceleration.

[0150] Figure 2 Schematic diagram of the structure of the query device of the vectorized database provided by the present invention. Figure 2 As shown, the device includes: a receiving module 210, a statement parsing module 220, a null value detection module 230 and a data processing module 240, wherein:

[0151] The receiving module is used to receive the query statement input by the user.

[0152] The statement parsing module is used to respond to the query statement and determine the target column data and the relational expression based on the query statement.

[0153] The null value detection module is used to obtain the null flag of each row in the query result based on the null flag of each row in the target column data.

[0154] The data processing module is used to obtain the query result based on the empty mark of each row in the query result, the target column data and the relational expression.

[0155] Specifically, the receiving module 210, the statement parsing module 220, the null value detection module 230 and the data processing module 240 are electrically connected in sequence.

[0156] The receiving module 210 receives a query statement input by a user.

[0157] The statement parsing module 220 parses the received query statement to obtain the data and data processing relation expressions under the fields corresponding to the query statement.

[0158] For any row in the target column data, the null value detection module 230 obtains the null flag of the query result of the row by performing corresponding logical operations according to the NULL operation rules on the null flag of each element in the target column data in the row, so as to know whether the query result of the row is NULL.

[0159] For any row in the target column data, the data processing module 240, the query device of the vectorized database performs logical operations on the empty marker of the query result of the row and each element of the target column data in the row, respectively, executes the relational expression parsed by the statement parsing module 220 on the multiple logical operation results, and obtains the query result after data processing.

[0160] Optionally, the device may further include:

[0161] The overflow detection module is used to output an overflow exception prompt when any row of the query result has overflow.

[0162] Optionally, the data processing module 240 may include a null value processing unit and a result processing unit, wherein:

[0163] A null value processing unit is used to perform a logical AND operation on the null flag of the target row in the query result and the element of the target row in each target column data for each target row, and obtain the null value processing result of the target row;

[0164] The result processing unit is used to determine the element of the target row in the query result based on the null value processing result of the target row and the relational expression.

[0165] Optionally, the null value detection module 230 may include a column null value detection unit and a result null value detection unit, wherein:

[0166] A column null value detection unit, used for obtaining, for each target row, a null flag of the target row in each target column data;

[0167] The result null value detection unit is used to perform a logical AND operation based on the null flag of the target row in the target column data to obtain the null flag of each row in the query result.

[0168] Optionally, the overflow detection module may include:

[0169] The overflow detection unit is used to perform overflow detection on the elements of the target row in the query result to determine whether there is overflow in the target row of the query result.

[0170] Optionally, the overflow exception prompt includes: the row numbers of each row in the query result where the overflow occurs.

[0171] The query device for a vectorized database provided in an embodiment of the present invention is used to execute the above-mentioned query method based on a vectorized database of the present invention. Its implementation method is consistent with the implementation method of the query method for a vectorized database provided by the present invention, and can achieve the same beneficial effects, which will not be repeated here.

[0172] The embodiment of the present invention obtains the empty flag of each row in the query result based on the empty flag of each row in the target column data, performs logical operations on the empty flag of each row in the query result and the target column data, executes the relational expression in the query statement and obtains the query result, which can reduce branch judgments to achieve performance acceleration.

[0173] Figure 3 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 3 As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330 and a communication bus 340, wherein the processor 310, the communication interface 320 and the memory 330 communicate with each other through the communication bus 340. The processor 310 may call the logic instructions in the memory 330 to execute the query method of the vectorized database, the method comprising: based on the query statement, determining the target column data and the relational expression; based on the empty mark of each row in the target column data, obtaining the empty mark of each row in the query result; based on the empty mark of each row in the query result, the target column data and the relational expression, obtaining the query result.

[0174] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0175] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the query method of the vectorized database provided by the above methods, and the method includes: receiving a query statement input by a user; responding to the query statement, and determining target column data and a relational expression based on the query statement; based on the empty flag of each row in the target column data, obtaining the empty flag of each row in the query result; based on the empty flag of each row in the query result, the target column data and the relational expression, obtaining the query result.

[0176] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the above-mentioned vectorized database query method, the method comprising: receiving a query statement input by a user; responding to the query statement, and determining target column data and a relational expression based on the query statement; obtaining an empty flag for each row in the query result based on the empty flag for each row in the target column data; obtaining the query result based on the empty flag for each row in the query result, the target column data, and the relational expression.

[0177] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0178] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0179] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for querying a vectorized database, characterized in that: include: Receive query statements input by users; In response to the query statement, determining target column data and a relational expression based on the query statement; Based on the empty flag of each row in the target column data, obtaining the empty flag of each row in the query result; The null flag is used to indicate whether the value of the data itself is NULL; Obtaining a query result based on the empty flag of each row in the query result, the target column data, and the relational expression; The acquiring the empty flag of each row in the query result based on the empty flag of each row in the target column data includes: For each target row, obtaining a null flag of the target row in each target column data; Performing a logical AND operation based on the empty flag of the target row in the target column data to obtain the empty flag of each row in the query result; The obtaining the query result based on the empty flag of each row in the query result, the target column data and the relational expression includes: For each target row, a null flag of the target row in the query result is logically ANDed with an element of the target row in each target column data to obtain a null value processing result of the target row; Based on the null value processing result of the target row and the relational expression, an element of the target row in the query result is determined.

2. The query method of the vectorized database according to claim 1, characterized in that: After obtaining the query result based on the empty flag of each row in the query result, the target column data and the relational expression, the method further includes: When overflow occurs in any row of the query result, an overflow exception prompt is output.

3. The query method of the vectorized database according to claim 1, characterized in that: After determining the element of the target row in the query result based on the null value processing result of the target row and the relational expression, the method further includes: Overflow detection is performed on elements of the target row in the query result to determine whether overflow exists in the target row of the query result.

4. The query method of a vectorized database according to claim 2, characterized in that: The overflow exception prompt includes: the row number of each row in the query result where overflow occurs.

5. A query device for a vectorized database, characterized in that: include: A receiving module, used for receiving a query statement input by a user; A statement parsing module, used for responding to the query statement and determining target column data and a relational expression based on the query statement; A null value detection module, used to obtain a null flag of each row in the query result based on the null flag of each row in the target column data; The null flag is used to indicate whether the value of the data itself is NULL; A data processing module, used for obtaining a query result based on the empty flag of each row in the query result, the target column data and the relational expression; The acquiring the empty flag of each row in the query result based on the empty flag of each row in the target column data includes: For each target row, obtaining a null flag of the target row in each target column data; Performing a logical AND operation based on the empty flag of the target row in the target column data to obtain the empty flag of each row in the query result; The obtaining the query result based on the empty flag of each row in the query result, the target column data and the relational expression includes: For each target row, a null flag of the target row in the query result is logically ANDed with an element of the target row in each target column data to obtain a null value processing result of the target row; Based on the null value processing result of the target row and the relational expression, an element of the target row in the query result is determined.

6. The query device for a vectorized database according to claim 5, characterized in that: Also includes: The overflow detection module is used to output an overflow exception prompt when any row of the query result has overflow.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the vectorized database query method as claimed in any one of claims 1 to 4 are implemented.

8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for querying a vectorized database as claimed in any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Database query method and server

    CN103970870A

  • SQL statement processing method and device, server and storage medium

    CN108304505A

  • Database query method and apparatus, server and storage medium

    CN108804554A

  • Database data operation method and system and server

    CN112650766A

  • Method of optimizing SQL queries where a predicate matches nullable operands

    US6996557B1