Data query method and apparatus, electronic device, and storage medium
By determining whether the data table connection column meets the data depression conditions, and updating the query statement to perform data restriction first and then connect internally, the invalid calculation problem during data table connection and restriction is solved, and the data query performance is improved.
Patent Information
- Application Number
- PCT/CN2024/126920
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-01
- Filing Date
- 2024-10-24
- Publication Date
- 2025-06-05
AI Technical Summary
When making connections and data restrictions in data tables, there are many invalid calculations, resulting in high system resource consumption, high time cost, and poor data query performance.
By determining whether the first and second connected columns meet the data depression conditions, if so, update the query statement so that they can perform data restriction before performing internal connection operations, thereby reducing the amount of data processing.
When the data is depressed, by first filtering the data table and then performing internal connection operations, the data processing volume and system resource consumption are reduced and data query performance is improved.
Smart Images

Figure CN2024126920_05062025_PF_FP_ABST
Abstract
Description
Data query method, device, electronic device and storage medium Technical Field
[0001] The present application relates to the field of database technology, and in particular to a data query method, device, electronic device, and storage medium. Background Art
[0002] In real-world business scenarios, it's often necessary to perform an inner join on two tables to obtain a query result set containing the joined rows. Then, using a restriction clause such as a limit, the query result set can be restricted. An inner join query searches for rows in two tables that match an equality condition and combines the matching rows.
[0003] However, when performing inner join operations and data restrictions on two data tables, there are usually many invalid calculations, which consumes a lot of system resources and time costs, and has poor data query performance.
[0004] Summary of the Invention
[0005] The purpose of the embodiments of the present application is to provide a data query method, device, electronic device, and storage medium, so as to improve data query performance when performing data query.
[0006] An embodiment of the present application provides a data query method, including: obtaining a first query statement to be queried; the first query statement is a statement used to perform an inner join on two data tables and then perform data restrictions based on a restriction sub-statement; according to the first query statement, determining a first data table and a second data table for an inner join operation, as well as a first join column for the inner join operation in the first data table and a second join column for the inner join operation in the second data table; according to the first query statement, judging whether the first join column and the second join column meet a data push condition; the data push condition is determined based on whether a value range of the first join column and a value range of the second join column have an inclusion relationship; if it is determined that the data push condition is met, updating the first query statement to obtain a second query statement; the second query statement is used to perform data restrictions on the data tables and then perform an inner join operation; according to the second query statement, performing data query on the first data table and the second data table to obtain a data query result.
[0007] In some embodiments, based on the first query statement, whether the first connection column and the second connection column meet the data push condition, including: based on the first query statement, judging whether the inclusion relationship judgment condition is met; the inclusion relationship judgment condition is determined based on the structure of the data table; if it is determined that the inclusion relationship judgment condition is met, and there is a foreign key constraint relationship between the first connection column and the second connection column or the inner join operation is a self-join operation, then it is determined that there is an inclusion relationship; based on the specified predicate operator included in the first query statement in addition to the inner join sub-statement, judging whether the data push condition is met; the inner join sub-statement is a sub-statement in the first query statement used for the inner join operation.
[0008] In some embodiments, based on the first query statement, determining whether the inclusion relationship judgment condition is met includes: if, based on the first query statement, it is determined that the first data table and the second data table are both basic tables, then determining that the inclusion relationship judgment condition is met; if, based on the first query statement, it is determined that there is a derived table in the first data table and the second data table, then determining whether the inclusion relationship judgment condition is met based on the sub-query statement corresponding to the derived table; the derived table is a virtual table constructed based on the sub-query statement in the first query statement.
[0009] In some embodiments, based on the sub-query statement corresponding to the derived table, it is determined whether the inclusion relationship judgment condition is met, including: if it is determined that the sub-query statement contains a specified connection operator, it is determined that the inclusion relationship judgment condition is not met; if it is determined that the sub-query statement contains an aggregation operator for connection column operations, and does not contain an extreme value operator for output operations of the aggregation operator, it is determined that the inclusion relationship judgment condition is not met; if it is determined that the sub-query statement contains a specified filtering operator, and the filtering range of the specified filtering operator does not meet the set filtering condition, it is determined that the inclusion relationship judgment condition is not met; if it is determined that the sub-query statement does not contain the specified connection operator, the aggregation operator and the specified filtering operator, it is determined that the inclusion relationship judgment condition is met; if it is determined that the sub-query statement contains an aggregation operator and an extreme value operator, and does not contain the specified connection operator and the specified filtering operator, it is determined that the inclusion relationship judgment condition is met; if it is determined that the sub-query statement contains an aggregation operator, an extreme value operator and a specified filtering operator, does not contain the specified connection operator, and meets the set filtering condition, it is determined that the inclusion relationship judgment condition is met.
[0010] In some embodiments, if it is determined that the sub-query statement contains a specified filtering operator and the filtering range of the specified filtering operator does not meet the set filtering conditions, it is determined that the inclusion relationship judgment condition is not met, including: according to the specified filtering operator, respectively determining the filtering range of the first data table and the second data table; if the filtering ranges corresponding to the first data table and the second data table respectively do not have an overlapping relationship, it is determined that the set filtering conditions are not met.
[0011] In some embodiments, whether the data push condition is met is determined based on the specified predicate operator included in the first query statement in addition to the inner join sub-statement, including: if it is determined that the first query statement does not include the specified predicate operator, then it is determined that the data push condition is met; otherwise, it is determined that the data push condition is not met; if it is determined that the first query statement also includes the specified predicate operator, and the associated data table of the specified predicate operator is consistent with the data table where the included join column is located, then it is determined that the data push condition is met; otherwise, it is determined that the data push condition is not met; the associated data table is the data table operated by the specified predicate operator.
[0012] In some embodiments, the first query statement is updated to obtain a second query statement, including: according to the inclusion relationship, the data table where the included connection column is located is used as the target data table; based on the restriction sub-statement in the first query statement, a target sub-statement is generated for restricting the data of the target data table; a conditional sub-statement is generated for restricting the connection column of the target data table to be not empty; the first query statement, the target sub-statement and the conditional sub-statement are combined to obtain the second query statement.
[0013] An embodiment of the present application provides a data query device, including: an acquisition unit, used to acquire a first query statement to be queried; the first query statement is a statement used to perform an inner join on two data tables and then perform data restrictions based on a restriction sub-statement; a determination unit, used to determine, based on the first query statement, a first data table and a second data table for an inner join operation, as well as a first connection column in the first data table for the inner join operation and a second connection column in the second data table for the inner join operation; a judgment unit, used to judge, based on the first query statement, whether the first connection column and the second connection column meet a data push condition; the data push condition is determined based on whether there is an inclusion relationship between the value range of the first connection column and the value range of the second connection column; an update unit, used to update the first query statement if it is determined that the data push condition is met, to obtain a second query statement; the second query statement is used to perform data restrictions on the data tables and then perform an inner join operation; and a query unit, used to perform data query on the first data table and the second data table based on the second query statement to obtain a data query result.
[0014] In some embodiments, the judgment unit is configured to: judge, based on the first query statement, whether a containment relationship judgment condition is met; the containment relationship judgment condition is determined based on the structure of the data table; if it is determined that the containment relationship judgment condition is met, and a foreign key constraint relationship exists between the first join column and the second join column, or the inner join operation is a self-join operation, then determine that a containment relationship exists;
[0015] Whether the data push condition is met is determined based on a specified predicate operator included in the first query statement in addition to the inner join sub-statement; the inner join sub-statement is a sub-statement in the first query statement used for the inner join operation.
[0016] In some embodiments, the judgment unit is used to: if it is determined according to the first query statement that the first data table and the second data table are both basic tables, then it is determined that the inclusion relationship judgment condition is met; if it is determined according to the first query statement that there is a derived table in the first data table and the second data table, then according to the sub-query statement corresponding to the derived table, it is determined whether the inclusion relationship judgment condition is met; the derived table is a virtual table constructed based on the sub-query statement in the first query statement.
[0017] In some embodiments, the judgment unit is used to: if it is determined that the sub-query statement contains a specified connection operator, then it is determined that the inclusion relationship judgment condition is not met; if it is determined that the sub-query statement contains an aggregation operator for connection column operations, and does not contain an extreme value operator for output operations of the aggregation operator, then it is determined that the inclusion relationship judgment condition is not met; if it is determined that the sub-query statement contains a specified filtering operator, and the filtering range of the specified filtering operator does not meet the set filtering condition, then it is determined that the inclusion relationship judgment condition is not met; if it is determined that the sub-query statement does not contain the specified connection operator, the aggregation operator and the specified filtering operator, then it is determined that the inclusion relationship judgment condition is met; if it is determined that the sub-query statement contains an aggregation operator and an extreme value operator, and does not contain the specified connection operator and the specified filtering operator, then it is determined that the inclusion relationship judgment condition is met; if it is determined that the sub-query statement contains an aggregation operator, an extreme value operator and a specified filtering operator, does not contain the specified connection operator, and meets the set filtering condition, then it is determined that the inclusion relationship judgment condition is met.
[0018] In some embodiments, the judgment unit is used to: determine the filtering range of the first data table and the second data table respectively according to the specified filtering operator; if the filtering ranges corresponding to the first data table and the second data table respectively do not overlap, it is determined that the set filtering conditions are not met.
[0019] In some embodiments, the judgment unit is used to: if it is determined that the first query statement does not contain the specified predicate operator, then it is determined that the data push condition is met; otherwise, it is determined that the data push condition is not met; if it is determined that the first query statement also contains the specified predicate operator, and the associated data table of the specified predicate operator is consistent with the data table where the included connection column is located, then it is determined that the data push condition is met; otherwise, it is determined that the data push condition is not met; the associated data table is the data table operated by the specified predicate operator.
[0020] In some embodiments, the update unit is used to: based on the inclusion relationship, take the data table where the included connection column is located as the target data table; based on the restriction sub-statement in the first query statement, generate a target sub-statement for restricting the data of the target data table; generate a conditional sub-statement for restricting the connection column of the target data table to be not empty; combine the first query statement, the target sub-statement and the conditional sub-statement to obtain the second query statement.
[0021] An embodiment of the present application provides an electronic device, including: a processor; and a memory storing computer instructions, wherein the computer instructions are used to enable the processor to execute the steps of the method provided in any of the various optional implementations of any of the above-mentioned data queries.
[0022] An embodiment of the present application provides a storage medium storing computer instructions, which are used to enable a computer to execute the steps of the method provided in any of the various optional implementations of any of the above-mentioned data queries.
[0023] In the data query method, device, electronic device and storage medium provided by the embodiment of the present application, a first query statement to be queried is obtained; the first query statement is a statement for performing an inner join on two data tables and then performing data restrictions based on a restriction sub-statement; according to the first query statement, a first data table and a second data table for the inner join operation are determined, as well as a first connection column for the inner join operation in the first data table and a second connection column for the inner join operation in the second data table; according to the first query statement, whether the first connection column and the second connection column meet the data push condition is determined; the data push condition is determined based on whether there is an inclusion relationship between the value range of the first connection column and the value range of the second connection column; if it is determined that the data push condition is met, the first query statement is updated to obtain a second query statement; the second query statement is used to perform data restrictions on the data table and then perform the inner join operation; according to the second query statement, data query is performed on the first data table and the second data table to obtain a data query result. In this way, when the data push condition is met, the data table can be filtered first and then the inner join operation is performed, thereby reducing the data processing amount and improving data query performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the specific embodiments of the present application, the following is a brief introduction to the drawings required for use in the description of the specific embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0025] FIG1 is a flow chart of a method for data query in an embodiment of the present application.
[0026] FIG2 is a detailed flow chart of a data query method in an embodiment of the present application.
[0027] FIG3 is a structural block diagram of a data query device in an embodiment of the present application.
[0028] FIG4 is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0029] The technical solutions of the present application will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. In addition, the technical features involved in the different embodiments of the present application described below can be combined with each other as long as they do not conflict with each other.
[0030] First, some of the terms involved in the embodiments of the present application are explained to facilitate understanding by those skilled in the art.
[0031] Terminal device: can be a mobile terminal, fixed terminal or portable terminal, such as a mobile phone, station, unit, device, multimedia computer, multimedia tablet, Internet node, communicator, desktop computer, laptop computer, notebook computer, netbook computer, tablet computer, personal communication system device, personal navigation device, personal digital assistant, audio / video player, digital camera / camcorder, positioning device, television receiver, radio broadcast receiver, e-book device, gaming device or any combination thereof, including accessories and peripherals of these devices or any combination thereof. It is also foreseeable that the terminal device can support any type of user interface (such as wearable device), etc.
[0032] Server: It can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and big data and artificial intelligence platforms.
[0033] Inner join: A relational algebra join method that returns rows with equal matching values in two data tables.
[0034] A self-join is a special equijoin within an inner join query. A self-join joins a table with its own table. The two columns involved in a self-join are essentially the same column, and all rows correspond one-to-one. Therefore, any table can be pushed down (i.e., filtered). Note that since databases may contain partitioned tables, the columns involved in a self-join must be in the same table, column, and partition for the join to work.
[0035] Basic table: It is an independent table. In Structured Query Language (SQL), one relation corresponds to one table.
[0036] Derived table: A subquery result set obtained based on a subquery statement contained in a query statement. It is a named temporary table (i.e., a virtual table).
[0037] Limit statement: used to return a specified number of rows from a data query result set.
[0038] Filterability: refers to whether the output result of an operation has fewer rows than the input data.
[0039] Foreign key: A field in one table corresponds to a field in another table and is used to indicate the relationship between the two tables.
[0040] The technical concept of this application is described below.
[0041] In real-world business scenarios, it's often necessary to perform an inner join between two tables and then push down data using a limit statement to implement data restrictions. For example, the two tables involved in the join are a student data table and a student performance table. The join column in the student data table is the student ID, and the join column in the student performance table is also the student ID. If the student ID in the first row of the student data table is 002, and the student ID in the third row of the student performance table is also 002, then the first and third rows are determined to be equal, and the two rows are joined.
[0042] However, when performing inner join operations and data restrictions on two data tables, there are usually many invalid calculations, which consumes a lot of system resources and time costs, and has poor data query performance.
[0043] Under traditional technology, it is usually possible to push down the data table before performing the left outer join, and then perform the left outer join operation. However, this method cannot be applied to the push down scenario of the inner join.
[0044] Based on the defects of the above-mentioned related technologies, the embodiments of the present application provide a data query method, device, electronic device and storage medium, which aim to reduce the data processing volume and improve data query performance when performing data query.
[0045] The present application provides a method for data querying, which can be applied to electronic devices. The present application does not limit the type of electronic device, and the method can be any device type suitable for implementation, such as a smartphone, tablet computer, etc. The present application will not elaborate on this. In the embodiments of the present application, the application is described using an example of applying to a database (e.g., Ocean Base).
[0046] 1 , which is a flow chart of a method for data query in an embodiment of the present application, the method will be described below in conjunction with FIG1 . The method includes steps 100 to 104 .
[0047] Step 100: Obtain a first query statement to be queried.
[0048] The first query statement is a statement for performing an inner join operation on two data tables and then performing data restriction based on a restriction sub-statement. Specifically, the first query statement includes an inner join sub-statement for performing an inner join operation on the first data table and the second data table and a restriction sub-statement.
[0049] As an example, an inner join clause can be an INNER JOIN clause or a JOIN clause, which compares each record (i.e., each row) in the first data table, table1, with each record in the second data table, table2, to find pairs of records that satisfy an equal match and then merges each pair of equal-matching records into a new result row. A restriction clause is a clause used to restrict data, which can be implemented using data pushdown (e.g., limit).
[0050] It should be noted that, in the embodiment of the present application, equal value matching of the inner join means that the column value of the first join column in table1 is the same as the column value of the second join column in table2.
[0051] Step 101: According to a first query statement, determine a first data table and a second data table for an inner join operation, as well as a first connection column for the inner join operation in the first data table and a second connection column for the inner join operation in the second data table.
[0052] Specifically, the first data table and the second data table are two data tables used for inner join operation; the first join column and the second join column are join columns used for inner join operation in corresponding data tables respectively.
[0053] In some embodiments, the first query statement includes the names of the first data table, the first connection column, the second data table, and the second connection column. Therefore, the first data table, the first connection column, the second data table, and the second connection column can be directly obtained from the first query statement. As an example, the first query statement includes T1 and T2, where T1 and T2 are the table names of the first data table and the second data table, respectively.
[0054] In some embodiments, at least one of the first data table, the first connection column, the second data table, and the second connection column is generated based on a sub-statement in the first query statement. Therefore, the first query statement does not directly contain the table name or column name of the inner join.
[0055] As an example, the first query statement includes T1 and a subquery statement q based on T1, T1 is the first data table, and the data table formed by the subquery statement q is the second data table.
[0056] Step 102: According to the first query statement, determine whether the first connection column and the second connection column meet the data push condition.
[0057] The data push condition is determined based on whether the value range of the first connection column and the value range of the second connection column have an inclusion relationship. It should be noted that the value range of the connection column refers to the set of values in each column of the connection column.
[0058] In some embodiments, when executing step 102, steps S1021 to S1023 may be included.
[0059] S1021: According to the first query statement, determine whether the inclusion relationship judgment condition is met.
[0060] Among them, the inclusion relationship judgment condition is determined according to the structure of the data table.
[0061] In some embodiments, when executing S1021, the following methods may be used:
[0062] Method 1: If the first query statement determines that both the first and second data tables are base tables, then the inclusion relationship criteria are met. It should be noted that base tables are independent tables, and in SQL, a relationship corresponds to a single table.
[0063] The second method: if it is determined according to the first query statement that a derived table exists in the first data table and the second data table, then it is determined according to the subquery statement corresponding to the derived table whether the inclusion relationship judgment condition is met.
[0064] A derived table is a virtual table constructed based on a subquery in the first query. It is a temporary table with a name assigned by the user in SQL. For example, in the statement select * from (select * from athors) temp, temp is a derived table.
[0065] In some embodiments, when executing the second method, the following methods may be used:
[0066] Method 1: If the subquery statement contains a specified join operator, the inclusion condition is determined to be unsatisfactory. A specified join operator is an operator used for joins. For example, the specified join operator can be "join." In practice, the specified join operator can be set based on the actual application scenario and is not restricted here.
[0067] Method 2: If it is determined that the subquery statement contains an aggregation operator that operates on the join column, but does not contain an extreme value operator that operates on the output of the aggregation operator, it is determined that the inclusion relationship judgment condition is not met.
[0068] For example, if the aggregation operator is aggr and the extreme value operators include min and max, then the subquery statement can contain aggr and min, respectively. This is used to perform an aggregation operation on the first column of the data table (i.e., the join column) using the aggregation operator aggr, and then determine the minimum value of each aggregation using the extreme value operator min.
[0069] Method 3: If it is determined that the subquery statement contains the specified filter operator and the filter range of the specified filter operator does not meet the set filter condition, it is determined that the inclusion relationship judgment condition is not met.
[0070] As an example, a specified filter operator can include at least one of the following: where-condition, semi-join, and limit. A specified filter operator is an operator used for filtering. In practice, the specified filter operator can be set based on the actual application scenario and is not limited here.
[0071] In some embodiments, the filtering ranges of the first data table and the second data table are determined respectively according to a specified filtering operator; if the filtering ranges corresponding to the first data table and the second data table do not overlap, it is determined that the set filtering condition is not met.
[0072] As an example, the first and second data tables are both derived tables, generated by the first and second subqueries in the first query statement, respectively. The first subquery statement includes the first specified filter operator "where id>10" and the second specified filter operator "where id>0." Obviously, the filter range of "where id>0" covers the filter range of "where id>10."
[0073] It should be noted that if the first query statement contains only one specified filter operator, it can be determined that the filter ranges of the two are inclusive, because the unfiltered global range must cover the filtered local range.
[0074] Method 4: If it is determined that the subquery statement does not contain the specified join operator, aggregation operator, and specified filter operator, it is determined that the inclusion relationship judgment condition is met.
[0075] Method 5: If it is determined that the subquery statement contains an aggregation operator and an extreme value operator, and does not contain a specified join operator or a specified filter operator, it is determined that the inclusion relationship judgment condition is met.
[0076] Method 6: If it is determined that the subquery statement contains an aggregation operator, an extreme value operator, and a specified filtering operator, does not contain a specified join operator, and meets the set filtering conditions, then it is determined that the inclusion relationship judgment condition is met.
[0077] S1022: If it is determined that the inclusion relationship judgment condition is met, and there is a foreign key constraint relationship between the first connection column and the second connection column or the inner connection operation is a self-join operation, then it is determined that there is an inclusion relationship.
[0078] It's important to note that setting up a foreign key constraint requires at least two tables: the table being constrained is called the detail table (child table), and the other is called the master table (parent table), forming a master-detail relationship. A foreign key constraint is used to establish a link between two tables' data. A field (another name for a column) in one table is constrained by the corresponding field in another table.
[0079] As an example, the first data table is the master table, the second data table is the slave table, and the connection columns in the first and second data tables are both field A. Then, field A in the first data table can be used as the foreign key of the second data table.
[0080] Therefore, the set of values in each column of the second connection column (ie, the range) must be included in the range of the first connection column.
[0081] Therefore, if there is a foreign key constraint relationship between the first connection column and the second connection column, it can be determined that there is a containment relationship.
[0082] Furthermore, since a self-join is a special equijoin in an inner join query, the so-called self-join refers to joining a table with its own current table. Therefore, if a self-join operation is performed on two data tables, it is essentially an inner join operation on two identical tables. Therefore, if an inner join is a self-join, there must be an inclusion relationship.
[0083] S1023: Determine whether the data push condition is met based on the specified predicate operator included in the first query statement in addition to the inner join sub-statement.
[0084] Optionally, the specified predicate operator can include at least one of the following functions: where-condition, order-by, and semi-join. The specified predicate operator can be used for operations such as filtering, sorting, and semi-join. In practice, the specified predicate operator can be set based on the actual application scenario and is not limited here.
[0085] In some embodiments, when executing S1023, the following methods may be used:
[0086] Method 1: If it is determined that the first query statement does not contain the specified predicate operator, it is determined that the data push condition is met.
[0087] Method 2: If it is determined that the first query statement also contains a specified predicate operator, and the associated data table of the specified predicate operator is consistent with the data table where the included join column is located, then it is determined that the data push condition is met; otherwise, it is determined that the data push condition is not met; the associated data table is the data table operated by the specified predicate operator.
[0088] Specifically, for ease of explanation, the data table containing the included join column is referred to as the target data table. If the value range of the first join column in the first data table contains the value range of the second join column in the second data table, the second data table is determined to be the target data table. Otherwise, the first data table is determined to be the target data table.
[0089] Step 103: If it is determined that the data push condition is met, the first query statement is updated to obtain a second query statement.
[0090] The second query statement is used to restrict the data in the data table and then perform an inner join operation.
[0091] In some embodiments, when executing step 103 , steps S1031 to S1034 may be included.
[0092] S1031: According to the inclusion relationship, the data table where the included connection column is located is used as the target data table.
[0093] S1032: Based on the restriction sub-statement in the first query statement, generate a target sub-statement for restricting data in the target data table.
[0094] The target sub-statement includes a restriction sub-statement and, optionally, other sub-statements for filtering. The restriction sub-statement is a sub-statement for data restriction, for example, it can be limit.
[0095] S1033: Generate a conditional sub-statement for restricting the connection column of the target data table to be non-empty.
[0096] S1034: Combine the first query statement, the target sub-statement, and the conditional sub-statement to obtain a second query statement.
[0097] Step 104: According to the second query statement, perform data query on the first data table and the second data table to obtain data query results.
[0098] In this way, you can first restrict the data on the target data table through the target sub-statement generated based on the restriction sub-statement, and then perform an inner join on the processed data table based on the not empty conditional sub-statement and the inner join sub-statement.
[0099] It should be noted that before performing an inner join on two data tables, a sufficient condition for pushing the data tables down is that the value ranges of the two data columns participating in the inner join exist in a containment relationship, that is, the inner join is filter-free. If the value range of the second join column contains the value range of the first join column, each row in the first data column can be matched with one or more rows in the second data column. Therefore, the inner join operation will succeed for each non-null row in the first data table and the second data table, and the number of rows obtained after the inner join operation will be greater than the number of rows in the first data table. In this case, the semantics of pushing data down on the first data table remain unchanged, that is, the query result of the inner join operation remains unchanged.
[0100] If both tables in the inner join operation are base tables, you only need to check whether the joining columns meet the foreign key constraints or whether it is a self-join, and whether the associated data table involved in the specified predicate operator is the target data table. If there is a derived table, you must first determine whether the subquery statement that constitutes the derived table meets the inclusion relationship judgment conditions to determine whether there are other factors that have destroyed the inclusion relationship. If it is determined that the inclusion relationship judgment conditions are met, then determine whether the derived table meets the foreign key constraints or whether it is a self-join, and whether the data table involved in the specified predicate operator is the target data table to be included.
[0101] In this way, when the data push conditions are met, the included target data table can be pushed down and then the inner join operation can be performed, thereby reducing the data processing volume and the cost consumed and improving data query performance.
[0102] The above embodiment will be described in detail below with reference to FIG. 2 . FIG. 2 is a detailed flow chart of a method for data query. The method will be described below with reference to FIG. 2 . The method includes steps 201 to 214 .
[0103] Step 201: Obtain a first query statement for an inner join operation.
[0104] Specifically, when it is determined that a query statement to be processed is received, if the query statement to be processed is a statement for an inner join operation, the query statement to be processed is determined to be the first query statement.
[0105] Furthermore, if the query statement to be processed is not a statement for an inner join operation, the query statement to be processed is directly executed, or a join mode of the query statement to be processed is determined and the query statement to be processed is executed according to other algorithms corresponding to the join mode.
[0106] Step 202: According to the first query statement, determine whether the two data tables are both basic tables. If so, execute step 203; otherwise, execute step 209.
[0107] In some embodiments, if the data table used for the inner join operation in the first query statement is an independent table, it is a basic table.
[0108] Furthermore, if the data table used for the inner join operation in the first query statement is a virtual table constructed by subquery statements in the first query statement, it is determined to be a derived table.
[0109] Step 203: Determine whether there is a containment relationship between the connection columns. If so, execute step 204; otherwise, execute step 208.
[0110] Specifically, if a foreign key constraint relationship exists between two connection columns (ie, the first connection column and the second connection column) or the inner connection operation is a self-connection operation, it is determined that a containment relationship exists; otherwise, it is determined that no containment relationship exists.
[0111] Step 204: Determine the target data table based on the inclusion relationship.
[0112] Step 205: Based on the specified predicate operator contained in the first query statement in addition to the inner join sub-statement and the target data table, determine whether the data push condition is met. If so, execute step 206; otherwise, execute step 208.
[0113] Specifically, the specified predicate operator can include at least one of the following: where-condition, order-by, and semi-join. If the associated data table operated by the specified predicate operator is the target data table, that is, the specified predicate operator in the first query statement is used to perform operations such as filtering and sorting on the target data table, then the data push condition is determined to be met.
[0114] In this way, if the data table involved in the specified predicate operator (ie, the associated data table) is the same as the data table to be pushed (ie, the target data table), the target data table can be pushed.
[0115] Step 206: Combine the first query statement, the target sub-statement, and the conditional sub-statement to obtain a second query statement.
[0116] Specifically, based on the restriction sub-statement in the first query statement, a target sub-statement is generated for restricting data in the target data table; a conditional sub-statement is generated for restricting the connection column of the target data table to be not empty; the first query statement, the target sub-statement and the conditional sub-statement are combined to obtain the second query statement.
[0117] This is because the inner join will not retain rows with null values in the join column, so it is necessary to add a condition that the join column is not null in the target data table to ensure the correctness of the semantics.
[0118] Step 207: Perform data query on the two data tables according to the second query statement to obtain data query results.
[0119] Specifically, through the second query statement, the target data table is first pushed down to obtain the pushed target data table, and then an inner join operation is performed on the pushed target data table and the remaining data tables to obtain the data query result.
[0120] The remaining data tables are data tables in the first data table and the second data table except the target data table, that is, the data tables in the first data table and the second data table including the target data table.
[0121] Step 208: End the process.
[0122] Step 209: Obtain a subquery statement for forming a derived table from the first query statement.
[0123] The subquery statement is a SELECT clause used to construct a derived table.
[0124] As an example, if the first data table or the second data table is a derived table, a corresponding subquery statement is obtained.
[0125] As another example, if the first data table and the second data table are both derived tables, then subquery statements corresponding to the first data table and the second data table are obtained.
[0126] In this way, the derived tables and their corresponding quantities can be determined according to the subquery statements in the first query statement.
[0127] Step 210 : Determine whether the subquery statement does not contain the specified join operator. If so, execute step 211 ; otherwise, execute step 208 .
[0128] The specified connection operator is a statement used for data connection.
[0129] As an example, the specified connection operator may be join.
[0130] Step 211: Determine whether there is an aggregate operator operating on the join column in the subquery statement. If so, execute step 212; otherwise, execute step 203.
[0131] The aggregation operator may be aggr.
[0132] Step 212: Determine whether there is an extreme value operator for the output operation of the aggregation operator in the subquery statement. If so, execute step 213; otherwise, execute step 208.
[0133] The maximum value operator may be max, and the minimum value operator may be min.
[0134] Step 213: Determine whether the subquery statement contains a specified filter operator. If so, execute step 214; otherwise, execute step 208.
[0135] The specified filtering operator is an operator used for data filtering.
[0136] Optionally, the specified filter operator may include at least one of the following: where-condition, semi-join, and limit.
[0137] Step 214: Determine whether the screening range of the specified screening operator meets the set screening conditions. If so, execute step 203; otherwise, execute step 208.
[0138] Specifically, when executing steps 201 to 214 , the specific steps refer to the above steps 100 to 104 , which are not described in detail here.
[0139] The above embodiment is illustrated below with a query statement. The following table statement is used to create table t1 (id int primary key, c1 int, c2 int). As can be seen from this table statement, t1 contains three columns, each with id, c1, and c2 as the primary key. A query statement for t1 is:
[0140] First, determine whether the query statement is the first query statement for an inner join operation. Specifically, because the query statement contains the inner join character "JOIN," it is determined to be the first query statement for an inner join operation. Furthermore, the first and second data tables for the inner join operation are view1 and view2, respectively. According to view1.aggr = view2.c1, the first join column for the inner join operation in view1 is view1.aggr, and the second join column for the inner join operation in view2 is view2.c1.
[0141] Next, the table type of each data table is determined based on the first query statement. Specifically, because the first query statement contains two subqueries that form derived tables—the first subquery statement corresponding to view1: SELECT id, MAX(c1) AS aggr FROM t1 WHERE id>10 GROUP BY id , and the second subquery statement corresponding to view2: SELECT c1 FROM t1 WHERE id>0 —both the first and second data tables in the first query statement are derived tables.
[0142] Next, we determine whether all subqueries contain a specified join operator. Therefore, we examine the aggregation operator for each subquery. Specifically, the first subquery contains the aggregation operator aggr for the first join column and the maximum operator MAX(c1) for this aggregation operator. This satisfies the condition of no specified join operator but the presence of an aggregation operator and an extreme value operator operating on the join columns. Furthermore, the second subquery contains neither a specified join operator nor an aggregation operator.
[0143] Furthermore, the query is judged based on whether the subquery contains the specified filter operator. Specifically, the first subquery contains the specified filter operator WHERE id>10 on the first join column, and the second subquery contains the specified filter operator WHERE id>0 on the second join column. Therefore, the filter range of WHERE id>0 covers the filter range of WHERE id>10, thus meeting the inclusion relationship judgment condition.
[0144] Next, we determine whether a containment relationship exists between the join columns. Specifically, we determine that the inner join operation is a self-join operation. This is because the column to which the first join column actually belongs is t1.c1, and the column to which the second join column actually belongs is also t1.c1. Furthermore, there are no partitions on table t1. Therefore, it is a self-join operation. Therefore, we determine that the range of the first join column is contained by the range of the second join column, and the first data table is the target data table.
[0145] Next, an update decision is made based on the specified predicate operators included in the first query statement, in addition to the inner join sub-statement. Specifically, the inner join sub-statement is the sub-statement in the first query statement that performs the inner join operation. Because the first query statement also includes the specified predicate operator ORDER BY, and based on the ORDER BY view1.id clause, it can be seen that ORDER BY is used to sort the first data table, i.e., the target data table, it meets the data push condition. Therefore, the target sub-statement, ORDER BY id limit 10, is generated to push the first data table downward and implement data restriction.
[0146] Furthermore, a conditional sub-statement, namely WHERE aggr IS NOT NULL, can be generated to restrict the connection column of the target data table to be not empty.
[0147] Next, combine the first subquery statement with the target subquery statement and the conditional subquery statement to obtain the new first data table newview:
[0148] ((SELECT id,MAX(c1)AS aggr FROM t1 WHERE id>10GROUP BY id)WHERE aggr IS NOT NULL ORDER BY id limit 10).
[0149] Furthermore, the first query statement is updated according to the new first sub-query statement to obtain the second query statement, namely:
[0150] SELECT*FROM((SELECT id,MAX(c1)AS aggr FROM t1 WHERE id>10GROUP BY id)
[0151] WHERE aggr IS NOT NULL ORDER BY id limit 10)newview JOIN
[0152] (SELECT c1 FROM t1 WHERE id>0)view2
[0153] ON newview.aggr=view2.c1
[0154] ORDER BY newview.id
[0155] LIMIT 10.
[0156] In the embodiment of the present application, whether the data push condition is met is determined based on whether the value range of the first join column and the value range of the second join column are included. If so, data is pushed down on the target data table included in the two data tables before the inner join operation is performed. This effectively reduces the amount of data processing, system resource consumption, and time cost of the join calculation, thereby improving data processing efficiency and data query performance. Furthermore, whether the two sides of the inner join are base tables or derived tables, it can be determined whether the push can be performed before the inner join. This can be applied to complex scenarios involving derived tables, has a wide range of applications, and provides convenience for users.
[0157] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0158] Based on the same inventive concept, the embodiments of this application also provide a data query device. Since the principles of the above-mentioned device and equipment for solving the problem are similar to those of a data query method, the implementation of the above-mentioned device can refer to the implementation of the method, and the repeated parts will not be repeated. The device can be applied to electronic devices. This application does not limit the type of electronic device. It can be any device type suitable for implementation, such as a smartphone, tablet computer, etc. This application will not repeat this.
[0159] Referring to FIG3 , which is a block diagram of a data query apparatus according to an embodiment of the present application, in some embodiments, the data query apparatus according to the present application example includes: an acquisition unit 301 for acquiring a first query statement to be queried; the first query statement is a statement for performing an inner join on two data tables and then performing data restrictions based on a restriction sub-statement; a determination unit 302 for determining, based on the first query statement, a first data table and a second data table for the inner join operation, as well as a first join column in the first data table for the inner join operation and a second join column in the second data table for the inner join operation; a determination unit 303 for determining, based on the first query statement, whether the first join column and the second join column meet a data push condition; the data push condition is determined based on whether a value range of the first join column and a value range of the second join column have an inclusion relationship; an update unit 304 for updating the first query statement to obtain a second query statement if it is determined that the data push condition is met; the second query statement is for performing data restrictions on the data tables and then performing an inner join operation; and a query unit 305 for performing a data query on the first data table and the second data table according to the second query statement to obtain a data query result.
[0160] In some embodiments, the judgment unit 303 is used to: judge whether the inclusion relationship judgment condition is met based on the first query statement; the inclusion relationship judgment condition is determined based on the structure of the data table; if it is determined that the inclusion relationship judgment condition is met, and there is a foreign key constraint relationship between the first connection column and the second connection column or the inner connection operation is a self-connection operation, then it is determined that there is an inclusion relationship; based on the specified predicate operator included in the first query statement in addition to the inner connection sub-statement, judge whether the data push condition is met; the inner connection sub-statement is the sub-statement in the first query statement used for the inner connection operation.
[0161] In some embodiments, the judgment unit 303 is used to: if it is determined according to the first query statement that the first data table and the second data table are both basic tables, then it is determined that the inclusion relationship judgment condition is met; if it is determined according to the first query statement that there is a derived table in the first data table and the second data table, then according to the sub-query statement corresponding to the derived table, it is determined whether the inclusion relationship judgment condition is met; the derived table is a virtual table constructed based on the sub-query statement in the first query statement.
[0162] In some embodiments, the judgment unit 303 is used to: if it is determined that the sub-query statement contains a specified connection operator, then it is determined that the inclusion relationship judgment condition is not met; if it is determined that the sub-query statement contains an aggregation operator for connection column operations, and does not contain an extreme value operator for output operations of the aggregation operator, then it is determined that the inclusion relationship judgment condition is not met; if it is determined that the sub-query statement contains a specified filtering operator, and the filtering range of the specified filtering operator does not meet the set filtering condition, then it is determined that the inclusion relationship judgment condition is not met; if it is determined that the sub-query statement does not contain the specified connection operator, the aggregation operator and the specified filtering operator, then it is determined that the inclusion relationship judgment condition is met; if it is determined that the sub-query statement contains an aggregation operator and an extreme value operator, and does not contain the specified connection operator and the specified filtering operator, then it is determined that the inclusion relationship judgment condition is met; if it is determined that the sub-query statement contains an aggregation operator, an extreme value operator and a specified filtering operator, does not contain the specified connection operator, and meets the set filtering condition, then it is determined that the inclusion relationship judgment condition is met.
[0163] In some embodiments, the judgment unit 303 is used to: determine the filtering range of the first data table and the second data table respectively according to the specified filtering operator; if the filtering ranges corresponding to the first data table and the second data table respectively do not overlap, it is determined that the set filtering condition is not met.
[0164] In some embodiments, the judgment unit 303 is used to: if it is determined that the first query statement does not contain the specified predicate operator, then it is determined that the data push condition is met; otherwise, it is determined that the data push condition is not met; if it is determined that the first query statement also contains the specified predicate operator, and the associated data table of the specified predicate operator is consistent with the data table where the included connection column is located, then it is determined that the data push condition is met; otherwise, it is determined that the data push condition is not met; the associated data table is the data table operated by the specified predicate operator.
[0165] In some embodiments, the update unit 304 is used to: based on the inclusion relationship, take the data table where the included connection column is located as the target data table; based on the restriction sub-statement in the first query statement, generate a target sub-statement for restricting the data of the target data table; generate a conditional sub-statement for restricting the connection column of the target data table to be not empty; combine the first query statement, the target sub-statement and the conditional sub-statement to obtain the second query statement.
[0166] In the data query method, device, electronic device and storage medium provided by the embodiment of the present application, a first query statement to be queried is obtained; the first query statement is a statement for performing an inner join on two data tables and then performing data restrictions based on a restriction sub-statement; according to the first query statement, a first data table and a second data table for the inner join operation are determined, as well as a first connection column for the inner join operation in the first data table and a second connection column for the inner join operation in the second data table; according to the first query statement, whether the first connection column and the second connection column meet the data push condition is determined; the data push condition is determined based on whether there is an inclusion relationship between the value range of the first connection column and the value range of the second connection column; if it is determined that the data push condition is met, the first query statement is updated to obtain a second query statement; the second query statement is used to perform data restrictions on the data table and then perform the inner join operation; according to the second query statement, data query is performed on the first data table and the second data table to obtain a data query result. In this way, when the data push condition is met, the data table can be filtered first and then the inner join operation is performed, thereby reducing the data processing amount and improving data query performance.
[0167] An embodiment of the present application provides an electronic device, including: a processor; and a memory storing computer instructions, wherein the computer instructions are used to enable the processor to execute a method in any of the above embodiments.
[0168] An embodiment of the present application provides a storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method of any of the above embodiments.
[0169] FIG4 shows a schematic structural diagram of an electronic device 4000. Referring to FIG4, the electronic device 4000 includes a processor 4010 and a memory 4020, and optionally, may further include a power supply 4030, a display unit 4040, and an input unit 4050.
[0170] The processor 4010 is the control center of the electronic device 4000 , which connects various components using various interfaces and lines, and performs various functions of the electronic device 4000 by running or executing software programs and / or data stored in the memory 4020 .
[0171] In the embodiment of the present application, the processor 4010 executes the various steps in the above embodiment when calling the computer program stored in the memory 4020.
[0172] Optionally, processor 4010 may include one or more processing units. Preferably, processor 4010 may integrate an application processor and a modem processor, wherein the application processor primarily processes the operating system, user interface, and applications, and the modem processor primarily processes wireless communications. It is understood that the modem processor may not be integrated into processor 4010. In some embodiments, the processor and memory may be implemented on a single chip. In some embodiments, they may also be implemented on separate chips.
[0173] The memory 4020 may mainly include a program storage area and a data storage area. The program storage area may store an operating system, various applications, etc., and the data storage area may store data created based on the use of the electronic device 4000. In addition, the memory 4020 may include a high-speed random access memory and a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device.
[0174] The electronic device 4000 also includes a power supply 4030 (such as a battery) for supplying power to various components. The power supply can be logically connected to the processor 4010 through a power management system, thereby managing functions such as charging, discharging, and power consumption through the power management system.
[0175] The display unit 4040 can be used to display information input by the user or information provided to the user, as well as various menus of the electronic device 4000. In the embodiment of the present application, it is mainly used to display the display interface of each application in the electronic device 4000 and objects such as text and pictures displayed on the display interface. The display unit 4040 may include a display panel 4041. The display panel 4041 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc.
[0176] The input unit 4050 can be used to receive information such as numbers or characters input by the user. The input unit 4050 may include a touch panel 4051 and other input devices 4052. The touch panel 4051, also known as a touch screen, can receive user touch operations on or near it (for example, operations performed by the user using a finger, a stylus, or any other suitable object or accessory on or near the touch panel 4051).
[0177] Specifically, the touch panel 4051 can detect user touch operations and the signals generated by the touch operations, convert these signals into touch point coordinates, send them to the processor 4010, and receive and execute commands sent by the processor 4010. In addition, the touch panel 4051 can be implemented using various types, such as resistive, capacitive, infrared, and surface acoustic wave. Other input devices 4052 can include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, power buttons, etc.), a trackball, a mouse, a joystick, etc.
[0178] Of course, the touch panel 4051 can cover the display panel 4041. When the touch panel 4051 detects a touch operation on or near it, it transmits the information to the processor 4010 to determine the type of touch event. The processor 4010 then provides a corresponding visual output on the display panel 4041 based on the type of touch event. Although in Figure 4, the touch panel 4051 and the display panel 4041 are used as two independent components to implement the input and output functions of the electronic device 4000, in some embodiments, the touch panel 4051 and the display panel 4041 can be integrated to implement the input and output functions of the electronic device 4000.
[0179] The electronic device 4000 may further include one or more sensors, such as a pressure sensor, a gravity acceleration sensor, a proximity light sensor, etc. Of course, according to the needs of specific applications, the electronic device 4000 may also include other components such as a camera. Since these components are not the key components used in the embodiments of the present application, they are not shown in FIG4 and will not be described in detail.
[0180] Those skilled in the art will understand that FIG4 is merely an example of an electronic device and does not limit the electronic device. The electronic device may include more or fewer components than shown in the figure, or may combine certain components or different components.
[0181] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.
[0182] Obviously, the above embodiments are merely examples for clarity of explanation and are not intended to limit the embodiments. Those skilled in the art will appreciate that other variations or modifications can be made based on the above description. It is not necessary and impossible to enumerate all embodiments here. Obvious variations or modifications arising therefrom remain within the scope of protection of this application.
Claims
1. A method for data query, the method comprising: Obtaining a first query statement to be queried; The first query statement is a statement for performing an inner connection on two data tables and then performing data restriction based on a restriction sub-statement; According to the first query statement, determine a first data table and a second data table for inner join operation, as well as a first connection column for inner join operation in the first data table and a second connection column for inner join operation in the second data table; According to the first query statement, determining whether the first connection column and the second connection column meet the data push condition; The data push condition is determined according to whether a value range of the first connection column and a value range of the second connection column have an inclusion relationship; If it is determined that the data push condition is met, the first query statement is updated to obtain a second query statement; the second query statement is used to restrict the data in the data table and then perform an inner join operation; According to the second query statement, data query is performed on the first data table and the second data table to obtain data query results.
2. The method according to claim 1, wherein: The determining, according to the first query statement, whether the first connection column and the second connection column meet the data push condition includes: According to the first query statement, whether a containment relationship determination condition is met; the containment relationship determination condition is determined according to the structure of the data table; If it is determined that the inclusion relationship judgment condition is met, and there is a foreign key constraint relationship between the first connection column and the second connection column or the inner connection operation is a self-connection operation, then it is determined that the inclusion relationship exists; Whether the data push condition is met is determined according to a specified predicate operator contained in the first query statement in addition to the inner join sub-statement; the inner join sub-statement is a sub-statement in the first query statement used for the inner join operation.
3. The method according to claim 2, wherein: The determining, according to the first query statement, whether a containment relationship determination condition is met includes: If it is determined according to the first query statement that the first data table and the second data table are both basic tables, it is determined that the inclusion relationship judgment condition is met; If it is determined according to the first query statement that there is a derived table in the first data table and the second data table, then according to the subquery statement corresponding to the derived table, it is judged whether the inclusion relationship judgment condition is met; the derived table is a virtual table constructed based on the subquery statement in the first query statement.
4. The method according to claim 3, wherein: The determining, based on the subquery statement corresponding to the derived table, whether the inclusion relationship determination condition is met includes: If it is determined that the subquery statement contains a specified join operator, it is determined that the inclusion relationship judgment condition is not met; If it is determined that the subquery statement contains an aggregation operator for the join column operation and does not contain an extreme value operator for the output operation of the aggregation operator, it is determined that the inclusion relationship judgment condition is not met; If it is determined that the subquery statement contains a specified filter operator, and the filter range of the specified filter operator does not meet the set filter condition, it is determined that the inclusion relationship judgment condition is not met; If it is determined that the subquery statement does not contain the specified join operator, the aggregation operator, and the specified screening operator, it is determined that the inclusion relationship judgment condition is met; If it is determined that the subquery statement contains the aggregation operator and the extreme value operator, and does not contain the specified connection operator and the specified screening operator, it is determined that the inclusion relationship judgment condition is met; If it is determined that the subquery statement contains the aggregation operator, the extreme value operator and the specified screening operator, does not contain the specified connection operator, and meets the set screening condition, it is determined that the inclusion relationship judgment condition is met.
5. The method according to claim 4, wherein: If it is determined that the subquery statement contains a specified filter operator, and the filter range of the specified filter operator does not meet the set filter condition, then determining that the inclusion relationship judgment condition is not met includes: According to the specified screening operator, respectively determine the screening range of the first data table and the second data table; If the screening ranges respectively corresponding to the first data table and the second data table do not overlap, it is determined that the set screening condition is not met.
6. The method according to any one of claims 2 to 5, wherein: The determining whether the data push condition is met according to the specified predicate operator contained in the first query statement in addition to the inner join substatement includes: If it is determined that the first query statement does not include the specified predicate operator, it is determined that the data push condition is met; otherwise, it is determined that the data push condition is not met; If it is determined that the first query statement also includes the specified predicate operator, and the associated data table of the specified predicate operator is consistent with the data table where the included connection column is located, it is determined that the data push condition is met; otherwise, it is determined that the data push condition is not met; the associated data table is the data table operated by the specified predicate operator.
7. The method according to any one of claims 1 to 5, wherein: The updating of the first query statement to obtain a second query statement includes: According to the inclusion relationship, the data table where the included connection column is located is used as the target data table; Based on the restriction sub-statement in the first query statement, generating a target sub-statement for filtering data in the target data table; Generate a conditional sub-statement for limiting the connection column of the target data table to be not empty; The first query statement, the target sub-statement and the conditional sub-statement are combined to obtain the second query statement.
8. A data query device, comprising: An acquisition unit, used for acquiring a first query statement to be queried; The first query statement is a statement for performing an inner connection on two data tables and then performing data restriction based on a restriction sub-statement; a determining unit, configured to determine, according to the first query statement, a first data table and a second data table for inner join operation, as well as a first connection column for inner join operation in the first data table and a second connection column for inner join operation in the second data table; a judging unit, configured to judge whether the first connection column and the second connection column meet a data push condition according to the first query statement; The data push condition is determined according to whether a value range of the first connection column and a value range of the second connection column have an inclusion relationship; An updating unit, configured to update the first query statement to obtain a second query statement if it is determined that the data push condition is met; The second query statement is used to restrict data in the data table and then perform an inner join operation; A query unit is used to perform data query on the first data table and the second data table according to the second query statement to obtain a data query result.
9. An electronic device, comprising: processor; as well as A memory storing computer instructions, wherein the computer instructions are used to enable the processor to execute the method according to any one of claims 1-7.
10. A storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data query method and device, electronic equipment and storage medium
CN117785935A
Optimizing relational database queries with multi-table predicate expressions
US20150324426A1
Optimizing nested database queries that include windowing operations
US9552392B2