Query statement processing method and related device

By generating target filter conditions and pushing down to branch statements of query statements, the query statement is optimized, and the query is inefficient in query caused by intersect all operation is solved, achieving more efficient query processing.

CN120256449APending Publication Date: 2025-07-04CETC JINCANG (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510630016.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-15
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

In the prior art, when the query statement contains the intersect all collection operation, the query efficiency is low because the semi join operation will remove duplicate data, while the intersect all operation retains duplicate data, resulting in the inability to effectively optimize.

Method used

By obtaining the branch statement filtering conditions of the query statement, generating the target filtering conditions, and pushing them down to each branch statement, the query statement is optimized to reduce the generation of intermediate result sets and improve query efficiency.

Benefits of technology

By reducing the amount of data generated by the intermediate result set of each branch statement and processed by the intersect node, the query efficiency of the query statement is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120256449A_ABST
    Figure CN120256449A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a query statement processing method and a related device, and relates to the technical field of databases, the method comprises the following steps: obtaining a to-be-processed query statement; under the condition that the query statement comprises a target set operation, obtaining a filtering condition of each branch statement of the query statement; the target set operation is used for obtaining an intersection of the result sets corresponding to the branch statements; generating a target filtering condition according to the filtering condition corresponding to each branch statement, and optimizing the query statement based on the target filtering condition to obtain a target query statement; and executing the target query statement. Through the method, the query efficiency of the query statement can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database technology, and in particular, to a query statement processing method and related device. Background Art

[0002] In a database system, query optimization is a core part of improving execution efficiency. For example, by converting set operations into semi-join operations to reduce computational overhead. However, for set operations that retain duplicate rows, the converted semi-join operations will automatically remove duplicates, resulting in an abnormal result set and low query efficiency. Summary of the Invention

[0003] Embodiments of this application provide a query statement processing method and related device, which can effectively improve the query efficiency of query statements.

[0004] In a first aspect, embodiments of this application provide a query statement processing method, including:

[0005] Obtain a query statement to be processed;

[0006] When the query statement includes a target set operation, obtain the filtering conditions of each branch statement of the query statement; the target set operation is used to obtain the intersection of the result sets corresponding to each branch statement;

[0007] Generate a target filtering condition according to the filtering conditions corresponding to each branch statement, and optimize the query statement based on the target filtering condition to obtain a target query statement;

[0008] Execute the target query statement.

[0009] In some embodiments, the generating a target filtering condition according to the filtering conditions of each branch statement includes:

[0010] If filtering conditions exist for target columns with the same sorting in the data tables corresponding to at least two branch statements, perform disjunction and conjunction on the filtering conditions corresponding to the target columns to obtain the target filtering condition corresponding to the target columns;

[0011] If only one target column with the same sorting in the data tables corresponding to each branch statement has the filtering condition, use the filtering condition as the target filtering condition.

[0012] In some embodiments, the optimizing the query statement based on the target filtering condition to obtain a target query statement includes:

[0013] Push the target filtering condition down to each branch statement of the query statement to obtain the optimized target query statement.

[0014] In some embodiments, pushing the target filtering condition down to each branch statement of the query statement includes:

[0015] For any branch statement, if there is no filtering condition for the target column corresponding to the target filtering condition, insert the target filtering condition into the target column;

[0016] If there is a filtering condition for the target column and it is different from the target filtering condition, replace the filtering condition with the target filtering condition.

[0017] In some embodiments, before generating the target filtering condition according to the filtering conditions corresponding to the respective branch statements, the method further includes:

[0018] If there is a filtering condition in the branch statement, delete the filtering condition.

[0019] In some embodiments, pushing the target filtering condition down to each branch statement of the query statement

[0020] For any one of the branch statements, insert the target filtering condition into the corresponding target column.

[0021] In some embodiments, the target set operation is an intersect operation or an intersect all operation.

[0022] In a second aspect, an embodiment of the present application provides a query statement processing device, including:

[0023] A first acquisition module, configured to acquire a query statement to be processed;

[0024] A second acquisition module, configured to acquire the filtering conditions of each branch statement of the query statement when the query statement includes a target set operation; the target set operation is used to obtain the intersection of the result sets corresponding to each branch statement;

[0025] A processing module, configured to generate a target filtering condition according to the filtering conditions corresponding to the respective branch statements, and optimize the query statement based on the target filtering condition to obtain a target query statement;

[0026] An execution module, configured to execute the target query statement.

[0027] In a third aspect, the present application provides an electronic device, including: a memory and a processor;

[0028] The memory is used to store computer instructions; the processor is used to run the computer instructions stored in the memory to implement the method according to any one of the first aspect.

[0029] Fourthly, the present application provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to implement the method according to any one of the first aspect.

[0030] Fifthly, the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, the method according to any one of the first aspect is implemented.

[0031] The query statement processing method and related device provided by the embodiments of the present application obtain a query statement to be processed; when the query statement includes a target set operation, obtain the filtering conditions of each branch statement of the query statement; the target set operation is used to obtain the intersection of the result sets corresponding to each branch statement; generate a target filtering condition according to the filtering conditions corresponding to each branch statement, and optimize the query statement based on the target filtering condition to obtain a target query statement; execute the target query statement. The above method can reduce the generation of intermediate result sets in each branch statement, reduce the amount of data processed by the intersect node, and thus improve the query efficiency of the query statement. Description of the Drawings

[0032] Figure 1 It is a schematic diagram of a set operation provided by an embodiment of the present application;

[0033] Figure 2 It is a schematic diagram of another set operation provided by an embodiment of the present application;

[0034] Figure 3 It is a schematic flowchart of a query statement processing method provided by an embodiment of the present application Figure 1 ;

[0035] Figure 4 It is a schematic flowchart of a query statement processing method provided by an embodiment of the present application Figure 2 ;

[0036] Figure 5 It is a schematic structural diagram of a query statement processing device provided by an embodiment of the present application;

[0037] Figure 6 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed Embodiments

[0038] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the following will clearly and completely describe the technical solutions in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Apparently, the described embodiments are some, but not all, of the embodiments of this application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of this application without creative efforts shall fall within the scope of protection of this application.

[0039] In the embodiments of this application, terms such as "first" and "second" are used to distinguish identical or similar items with basically the same functions and effects, and do not limit their order. Those skilled in the art can understand that terms such as "first" and "second" do not limit the quantity and execution order, and "first", "second", etc. do not necessarily mean different.

[0040] It should be noted that in the embodiments of this application, words such as "exemplary" or "for example" are used to represent examples, illustrations, or explanations. Any embodiment or design solution described as "exemplary" or "for example" in this application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present relevant concepts in a specific manner.

[0041] As Figure 1 shown, the intersect set operation is used to return the common part of two sets, that is, the data that appears in both the first query result and the second query result, and duplicate data in the result is excluded.

[0042] As Figure 2 shown, the intersect all set operation is used to return the common part of two sets, that is, the data that appears in both the first query result and the second query result, and duplicate data in the result is retained.

[0043] As mentioned above, for a query statement, the optimizer can convert the intersect set operation (also known as the intersect operation) in the query statement into a semi join operation to eliminate the intersect operation, thereby improving the query efficiency to a certain extent.

[0044] However, for the intersect all set operation (also known as the intersect all operation), since the all keyword will retain all data that meets the conditions, while the semi join will deduplicate the data, the intersect all set operation is not applicable, resulting in a lower query efficiency for query statements including the intersect all set operation.

[0045] In view of this, an embodiment of the present application provides a query statement processing method and related device. By processing the filtering conditions of the same columns in each branch statement of a query statement including a target set operation, new filtering conditions are obtained, and the new filtering conditions are used to optimize each branch statement, so as to reduce the amount of data processed by each branch statement and improve the query efficiency of the query statement.

[0046] The following uses specific embodiments to elaborate in detail on the technical solution of the present application and how the technical solution of the present application solves the above technical problems. These several specific embodiments can be implemented independently or in combination with each other. For the same or similar concepts or processes, they may not be repeated in some embodiments.

[0047] Figure 3 A flowchart of a query statement processing method provided by an embodiment of the present application is shown as Figure 3 shown, including the following steps:

[0048] S301. Obtain a query statement to be processed.

[0049] The execution subject of the embodiment of the present application can be an optimizer or an executor that processes the query statement. Hereinafter, the optimizer is taken as an example for illustration.

[0050] The optimizer can obtain the query statement input by the user from the outside.

[0051] S302. When the query statement includes a target set operation, obtain the filtering conditions of each branch statement of the query statement.

[0052] Among them, the target set operation is used to obtain the intersection of the result sets corresponding to each branch statement. For example, the target set operation can be an intersect operation or an intersect all operation.

[0053] In some embodiments, when the optimizer obtains the query statement, it can determine whether the query statement includes a target set operation by keyword recognition. For example, if it recognizes that the keyword intersect is included in the query statement, it can be determined that the query statement includes a target set operation.

[0054] In some embodiments, for a query statement including a target set operation, the optimizer can use the statements before and after the target set operation as each branch statement of the query statement. For example, for the following query statement:

[0055] select a, b from t1 where a < 5 and b = 4

[0056] intersect

[0057] select a, b from t2 where a < 10 and b < 3;

[0058] The query statement includes two branch statements, namely: select a, b from t1 where a < 5 and b = 4 and select a, b from t2 where a < 10 and b < 3.

[0059] After determining each branch statement in the query statement, the optimizer can separately obtain the filtering conditions in each branch statement. For example, the optimizer can perform syntax parsing and / or lexical parsing on each branch statement to identify the filtering conditions in each branch statement.

[0060] For example, for the query statement in the above example, for the branch statement select a, b from t1 where a < 5 and b = 4, the filtering condition for this branch statement is a < 5 and b = 4.

[0061] S303. Generate a target filtering condition according to the filtering conditions corresponding to each branch statement, and optimize the query statement based on the target filtering condition to obtain a target query statement.

[0062] In some embodiments, after obtaining the filtering conditions of each branch statement, the target filtering condition can be generated in the following manner:

[0063] In a possible implementation manner, if the filtering conditions exist for the target columns with the same sorting in the data tables corresponding to at least two of the branch statements, then perform disjunction and conjunction on the filtering conditions corresponding to the target columns to obtain the target filtering condition corresponding to the target columns.

[0064] For example, for query statement 1:

[0065] select a, b from t1 where a < 5 and b = 4

[0066] intersect

[0067] select a, b from t2 where a < 10 and b < 3;

[0068] The filtering condition for column a in branch statement 1 is a < 5, and the condition for column b is b = 4;

[0069] The filtering condition for column a in branch statement 2 is a < 10, and the condition for column b is b < 3;

[0070] Disjunctively and conjunctively process the filtering conditions for columns a and b respectively, and the target filtering condition for column a is obtained as: a < 5, and the target filtering condition for column b is: false.

[0071] In a possible implementation, if in the data tables corresponding to each of the branch statements, only one target column among the target columns with the same sorting has the filtering condition, then use the filtering condition as the target filtering condition.

[0072] For example, for query statement 2:

[0073] select a, b from t1

[0074] intersect

[0075] select a, b from t2 where a < 10

[0076] There is no filtering condition in branch statement 1, and the filtering condition for column a in branch statement 2 is a < 10, then use the filtering condition for column a in branch statement 2 as the target filtering condition for column a.

[0077] In some embodiments, after the optimizer obtains the target filtering condition, it can push down the target filtering condition to each branch statement of the query statement to replace the original filtering condition, thereby obtaining the optimized target query statement.

[0078] Exemplarily, for the above query statement 1, the target query statement obtained by pushing down the target filtering condition to each branch statement is as follows:

[0079] select a, b from t1 where a < 5 and false

[0080] intersect

[0081] select a, b from t2 where a < 5 and false

[0082] For the above query statement 2, the target query statement obtained by pushing down the target filtering condition to each branch statement is as follows:

[0083] select a, b from t1 where a < 10

[0084] intersect

[0085] select a, b from t2 where a < 10;

[0086] As can be seen from the above target query statement, by pushing down the target filtering condition, data in each branch statement can be filtered in advance, reducing the generation of intermediate result sets corresponding to each branch statement, thereby reducing the amount of data processed by the intersect node and effectively improving the query efficiency of the query statement.

[0087] S304. Execute the target query statement.

[0088] When obtaining the target query statement, the optimizer can perform other optimization processes in the prior art (such as cost evaluation) on the target query statement, and execute the target query statement to obtain the query result.

[0089] The query statement processing method provided by the embodiments of the present application includes: obtaining a query statement to be processed; when the query statement includes a target set operation, obtaining the filtering conditions of each branch statement of the query statement; the target set operation is used to obtain the intersection of the result sets corresponding to each branch statement; generating a target filtering condition according to the filtering conditions corresponding to each branch statement, and optimizing the query statement based on the target filtering condition to obtain a target query statement; executing the target query statement. By the above method, the generation of intermediate result sets in each branch statement can be reduced, and the amount of data processed by the intersect node can be reduced, thereby improving the query efficiency of the query statement.

[0090] Based on the above embodiments, the query statement processing method provided by the embodiments of the present application will be further described below in combination with Figure 4 As shown in the following

[0091] Figure 4 is a flowchart of the query statement processing method provided by the embodiments of the present application Figure 2 as Figure 4 shown, including:

[0092] S401. Obtain a query statement to be processed.

[0093] S402. When the query statement includes a target set operation, obtain the filtering conditions of each branch statement of the query statement.

[0094] In some embodiments, the specific implementation manners of the steps shown in S401 and S402 are similar to those of the steps shown in Figure 3 S301 and S302, and will not be described in detail here.

[0095] In some embodiments, after obtaining the filtering conditions of each branch statement of the query statement, the optimizer may execute the steps shown in S403 - S405 to complete the optimization of the query statement, or execute the steps shown in S404, S406, and S407 to complete the optimization of the query statement.

[0096] S403. If there is a filtering condition in the branch statement, delete the filtering condition.

[0097] Exemplarily, for the following query statement:

[0098] select a, b from t1 where a < 5 and b = 4

[0099] intersect

[0100] select a, b from t2 where a < 10 and b < 3;

[0101] If there are filtering conditions in both branch statements, after the optimizer obtains the filtering conditions of each branch statement, it deletes the filtering conditions in each branch statement.

[0102] Exemplarily, the query statement after deleting the filtering conditions is as follows:

[0103] select a, b from t1 where and

[0104] intersect

[0105] select a, b from t2 where and ;

[0106] S404. Generate a target filtering condition according to the filtering conditions corresponding to each branch statement.

[0107] Among them, the specific implementation manner of the step shown in S404 is similar to the specific implementation manner of the step shown in S303 in the above embodiments.

[0108] S405. For any one of the branch statements, insert the target filtering condition into the corresponding target column to obtain the optimized target query statement.

[0109] When obtaining the target filtering conditions corresponding to each target column of the branch statement, the target filtering condition can be inserted into the position where the filtering condition corresponding to the corresponding target column is located to obtain the target query statement.

[0110] The following introduces the process of generating a target query statement for several common types of query statements:

[0111] 1. Generate a target filtering condition based on the filtering conditions in the where clause.

[0112] a. The query statement is as follows:

[0113] select b, a from t1

[0114] intersect

[0115] select a, b from t2 where a < 10;

[0116] For the above statement, intersect takes the intersection of the result sets of columns b and a in table t1 in branch 1 and the result sets of columns a and b in table t2 in branch 2, that is, t1.b = t2.a and t1.a = t2.b.

[0117] There is no filtering condition in branch 1, and there is a filtering condition of a < 10 for the first column (column a) in branch 2. Then, the filtering condition of the first column in branch 2 can be used as the target filtering condition for the first column of each branch. That is, for each branch, the target filtering condition is the first column < 10 (for example, the first column in branch 1 is column b, and the target filtering condition is b < 10; the first column in branch 2 is column a, and the target filtering condition is a < 10).

[0118] Therefore, the optimized target query statement is as follows:

[0119] select b, a from t1 where b < 10

[0120] intersect

[0121] select a, b from t2 where a < 10;

[0122] b. The query statement is as follows:

[0123] select a, b from t1 where a < 5 and b = 4

[0124] intersect

[0125] select a, b from t2 where a < 10 and b < 3;

[0126] The filtering condition for branch 1 is that the first column (column a) is less than 5 and the second column (column b) is equal to 4. The filtering condition for branch 2 is that the first column (column a) is less than 10 and the second column (column b) is equal to 3.

[0127] Disjunct and conjunct the filtering conditions for the first column of Branch 1 and Branch 2, and the filtering condition for the first column obtained is a < 5; disjunct and conjunct the filtering conditions for the second column of Branch 1 and Branch 2, and the filtering condition for the first column obtained is false.

[0128] Therefore, the optimized target query statement is as follows:

[0129] select a, b from t1 where a < 5 and false

[0130] intersect

[0131] select a, b from t2 where a < 5 and false

[0132] 2. Generate the target filtering condition based on the filtering condition in the on clause.

[0133] The query statement is as follows:

[0134] select t1.b, t1.a from t1 join t2 on t1.a = t2.a and t2.a = 10

[0135] intersect all

[0136] select a, b from t3;

[0137] For the above statement, the first column of Branch 1 is the t1.b column, the second column is the t1.a column, and the filtering condition is t1.a = t2.a and t2.a = 10. From this filtering condition, the filtering condition of t1.a = 10 (the second column = 10) can be obtained. The first column of Branch 2 is the a column, the second column is the b column, and there is no filtering condition. Then, the filtering condition of the second column of Branch 1 (the second column = 10) can be used as the target filtering condition of the second column. That is, for Branch 2, the target filtering condition is b = 10 (t3.b = 10).

[0138] Therefore, the optimized target query statement is as follows:

[0139] select t1.b, t1.a from t1 join t2 on t1.a = t2.a and t2.a = 10

[0140] intersect all

[0141] select a, b from t3 where t3.b = 10;

[0142] 3. Generate a target filtering condition based on the constant values existing in the target column itself.

[0143] The query statement is as follows:

[0144] select t1.b, 10, ‘kingbase’ from t1

[0145] intersect all

[0146] select a, b, name from t3;

[0147] For branch 1, the first column is the t1.b column, and the second and third columns are constant values (fixed values) 10 and kingbase respectively. For branch 2, the first column is the a column, the second column is the b column, and the third column is the name column.

[0148] For branch 1, since the second and third columns are constant values, it can be considered that the filtering conditions for the second and third columns are to filter out the data where they are equal to the constant values. For branch 2, since there is no filtering condition, the filtering conditions for the second and third columns of branch 1 can be used as the target filtering conditions for the second and third columns respectively. That is, for branch 2, the target filtering condition for the second column is b = 10, and the filtering condition for the third column is name = ‘kingbase’.

[0149] Therefore, the optimized target query statement is as follows:

[0150] select t1.b, 10, ‘kingbase’ from t1

[0151] intersect all

[0152] select a, b, name from t3 where b = 10 and name = ‘kingbase’;

[0153] S406. For any branch statement, if there is no filtering condition for the target column corresponding to the target filtering condition, then insert the target filtering condition into the target column to obtain the optimized target query statement.

[0154] S407. If there is a filtering condition for the target column, then replace the filtering condition with the target filtering condition to obtain the optimized target query statement.

[0155] Exemplarily, the query statement as shown above:

[0156] select b, a from t1

[0157] intersect

[0158] select a, b from t2 where a < 10;

[0159] The target filtering condition for the first column is < 10. For branch 1, there is no filtering condition for the first column, so the target filtering condition can be directly inserted into the first column. For branch 2, the filtering condition for the first column is the same as the corresponding target filtering condition, so no processing is performed, thus obtaining the optimized target query statement.

[0160] Exemplarily, the query statement as shown above:

[0161] select a, b from t1 where a < 5 and b = 4

[0162] intersect

[0163] select a, b from t2 where a < 10 and b < 3;

[0164] The target filtering condition for the first column is a < 5, and the target filtering condition for the second column is false. For both branch 1 and branch 2, there are filtering conditions for the first and second columns, and their respective filtering conditions are different from the corresponding target filtering conditions, so the original filtering conditions are replaced with their respective corresponding target filtering conditions.

[0165] In summary, the query statement processing method provided by the embodiments of the present application integrates and processes the filtering conditions of the same column in each branch statement, obtains new filtering conditions corresponding to the same column, and pushes the new filtering down to the columns corresponding to each branch statement, so that each branch statement filters the data in advance to reduce the amount of data processed by the set operation, thereby improving the efficiency of the query statement.

[0166] Based on the above embodiments, the embodiments of the present application further provide a statement optimization device.

[0167] Figure 5 is a schematic structural diagram of the statement optimization device provided by the embodiments of the present application. As Figure 5 shown, it includes:

[0168] The first acquisition module 501 is used to acquire the query statement to be processed.

[0169] A second acquisition module 502, configured to, when a target set operation is included in the query statement, acquire filtering conditions of each branch statement of the query statement; the target set operation is used to acquire an intersection of result sets corresponding to the branch statements.

[0170] A processing module 503, configured to generate a target filtering condition according to the filtering conditions corresponding to the branch statements, and optimize the query statement based on the target filtering condition to obtain a target query statement.

[0171] An execution module 504, configured to execute the target query statement.

[0172] In some embodiments, the processing module 503 is further configured to, if filtering conditions exist for all target columns with the same sorting in data tables corresponding to at least two branch statements, perform disjunction and conjunction on the filtering conditions corresponding to the target columns to obtain a target filtering condition corresponding to the target columns; if among the target columns with the same sorting in the data tables corresponding to the branch statements, only one target column has the filtering condition, use the filtering condition as the target filtering condition.

[0173] In some embodiments, the processing module 503 is further configured to push down the target filtering condition to each branch statement of the query statement to obtain the optimized target query statement.

[0174] In some embodiments, the processing module 503 is further configured to, for any branch statement, if a filtering condition does not exist for a target column corresponding to the target filtering condition, insert the target filtering condition into the target column; if a filtering condition exists for the target column and is different from the target filtering condition, use the target filtering condition to replace the filtering condition.

[0175] In some embodiments, the processing module 503 is further configured to, if a filtering condition exists in the branch statement, delete the filtering condition.

[0176] In some embodiments, the processing module 503 is further configured to, for any branch statement, insert the target filtering condition into a corresponding target column.

[0177] In some embodiments, the target set operation is an intersect operation or an intersect all operation.

[0178] The statement optimization device provided in the embodiments of the present application can execute the statement optimization method provided in any of the above embodiments, and the principles and technical effects are similar, which will not be elaborated here.

[0179] The embodiments of the present application further provide an electronic device.

[0180] Figure 6 The structural schematic diagram of the electronic device 60 provided by the embodiment of the present application is as follows Figure 6 shown, including:

[0181] A processor 601.

[0182] A memory 602, configured to store executable instructions of the terminal device.

[0183] Specifically, the program may include program code, and the program code includes computer operation instructions. The memory 602 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory.

[0184] The processor 601 is configured to execute the computer execution instructions stored in the memory 602 to implement the technical solutions of the embodiments described in the foregoing method embodiments.

[0185] Among them, the processor 601 may be a central processing unit (abbreviated as CPU), or an application specific integrated circuit (abbreviated as ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.

[0186] Optionally, the electronic device 60 may further include a communication interface, through which communication interaction can be performed with an external device. The external device may be, for example, a user terminal (such as a mobile phone, a tablet). In a specific implementation, if the communication interface, the memory 602, and the processor 601 are implemented independently, the communication interface, the memory 602, and the processor 601 may be interconnected through a bus and communicate with each other.

[0187] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus.

[0188] Optionally, in a specific implementation, if the communication interface, the memory 602, and the processor 601 are integrated on a chip, the communication interface, the memory 602, and the processor 601 may complete communication through an internal interface.

[0189] In an embodiment of the present application, a computer-readable storage medium is further provided, on which a computer program is stored. When the computer program is executed by a processor, the technical solutions of the above embodiments are implemented, and the implementation principles and technical effects are similar, which will not be elaborated here.

[0190] In a possible implementation, the computer-readable medium may include a random access memory (RAM), a read-only memory (ROM), a compact disc read-only memory (CD-ROM), or other optical disc memories, a magnetic disk memory, or other magnetic storage devices, or any other medium suitable for carrying or storing the required program code in the form of instructions or data structures and accessible by a computer. Moreover, any connection is properly referred to as a computer-readable medium. For example, if software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of the medium. As used herein, magnetic disks and optical discs include optical discs, laser discs, optical discs, digital versatile discs (DVDs), floppy disks, and Blu-ray discs, where magnetic disks typically reproduce data magnetically, while optical discs use lasers to optically reproduce data. The above combinations should also be included within the scope of computer-readable media.

[0191] In an embodiment of the present application, a computer program product is further provided, including a computer program. When the computer program is executed by a processor, the technical solutions of the above embodiments are implemented, and the implementation principles and technical effects are similar, which will not be elaborated here.

[0192] In the specific implementation of the above terminal device or server, it should be understood that the processor may be a central processing unit (CPU for short), or other general-purpose processors, digital signal processors (DSP for short), application-specific integrated circuits (ASIC for short), etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present application can be directly implemented by the execution of the hardware processor, or can be implemented by the combination of hardware and software modules in the processor.

[0193] Those skilled in the art can understand that all or part of the steps of any of the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, all or part of the steps of the above method embodiments are executed.

[0194] If the technical solution of the present application is implemented in the form of software and sold or used as a product, it can be stored in a computer-readable storage medium. Based on such an understanding, all or part of the technical solution of the present application can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a computer program or several instructions. The computer software product enables a computer device (which can be a personal computer, a server, a network device or a similar electronic device) to execute all or part of the steps of the method described in the embodiments of the present application.

[0195] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to the present application.

[0196] Furthermore, it should be noted that although the steps in the flowchart are displayed in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same moment, but can be executed at different moments. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.

[0197] It should be understood that the above device embodiments are only illustrative, and the devices of the present application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0198] In addition, unless otherwise specified, in each embodiment of the present application, each functional unit / module may be integrated into one unit / module, may exist physically as individual units / modules, or may be integrated together with two or more units / modules. The above integrated unit / module may be implemented in the form of hardware or in the form of a software program module.

[0199] When the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor may be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit may be any suitable magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory (RRAM), a dynamic random access memory (DRAM), a static random access memory (SRAM), an enhanced dynamic random access memory (EDRAM), a high-bandwidth memory (HBM), a hybrid memory cube (HMC), etc.

[0200] When the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it may be stored in a computer-readable memory. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, may be embodied in the form of a software product. The computer software product is stored in a memory and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in each embodiment of the present application. The aforementioned memory includes: USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs, etc., which are various media that can store program codes.

[0201] In the above embodiments, the descriptions of the respective embodiments have their own emphases. For parts not elaborated in a certain embodiment, reference may be made to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as falling within the scope described in this specification.

[0202] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit them. Although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A query statement processing method, characterized in that: Obtain a query statement to be processed; When the query statement includes a target set operation, obtain the filtering conditions of each branch statement of the query statement; The target set operation is used to obtain the intersection of the result sets corresponding to each of the branch statements; Generate a target filtering condition according to the filtering conditions corresponding to each branch statement, and optimize the query statement based on the target filtering condition to obtain a target query statement; Execute the target query statement.

2. The method according to claim 1, wherein The generating a target filtering condition according to the filtering conditions of each branch statement includes: If the filtering conditions exist for the target columns with the same sorting in the data tables corresponding to at least two of the branch statements, perform disjunction and conjunction on the filtering conditions corresponding to the target columns to obtain the target filtering condition corresponding to the target columns; If only one of the target columns with the same sorting in the data tables corresponding to each of the branch statements has the filtering condition, use the filtering condition as the target filtering condition.

3. The method according to claim 2, characterized in that, The optimizing the query statement based on the target filtering condition to obtain a target query statement includes: Push the target filtering condition down to each branch statement of the query statement to obtain the optimized target query statement.

4. The method according to claim 3, characterized in that, The pushing the target filtering condition down to each branch statement of the query statement includes: For any branch statement, if the target column corresponding to the target filtering condition does not have a filtering condition, insert the target filtering condition into the target column; If the target column has a filtering condition and is different from the target filtering condition, use the target filtering condition to replace the filtering condition.

5. The method according to claim 3, wherein Before the generating a target filtering condition according to the filtering conditions corresponding to each branch statement, the method further includes: If there is a filtering condition in the branch statement, delete the filtering condition.

6. The method according to claim 5, wherein Push the target filtering condition down to each branch statement of the query statement, For any one of the branch statements, insert the target filtering condition into the corresponding target column.

7. The method according to any one of claims 1 to 6, characterized in that, The target set operation is an intersect operation or an intersect all operation.

8. An electronic device, characterized in that, Including: A memory for storing a computer program; A processor for executing the computer program to implement the method according to any one of claims 1-7.

9. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and the computer program is executed by a processor to implement the method according to any one of claims 1-7.

10. A computer program product, characterized in that, Including a computer program, which implements the method according to any one of claims 1-7 when executed by a controller.