A data processing method, device, apparatus, and storage medium
By determining whether the two query branches of a set query statement are the same and rewriting the statement according to the operation type, it is optimized into a single-branch operation, which solves the problem of low efficiency in the existing technology and realizes a more efficient set query.
Patent Information
- Application Number
- CN202211506106.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-28
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2042-11-28
AI Technical Summary
Existing technologies require calculating the result sets of the left and right query branches separately and performing set operations when executing set queries, resulting in low efficiency, especially when the execution efficiency of a single branch is low.
By determining whether the two query branches of a set query statement are the same, if they are the same, the statement is rewritten according to the set operation type, and optimized into a single query branch operation, such as deduplication, intersection, difference, etc., to avoid duplicate calculations.
It improves the execution efficiency of set queries, reduces redundant calculations, and enhances overall query performance.
Smart Images

Figure CN115712645B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of computer, and particularly relate to a data processing method, device, equipment and storage medium. BACKGROUND
[0002] Set query is a common query means in structured query language (SQL). Since the query result of SQL statement is a set of tuples, the results of multiple SQL statements can be operated in set. Set operation mainly includes union (UNION), intersection (INTERSECT) and difference (EXCEPT).
[0003] In set operation, since the two query branches on both sides of the operator are equivalent, the result set is also the same. In the conventional method, when actually executing the set operation, the result sets of the left and right query branches are calculated respectively, and then the set operation is performed on the two result sets. When the execution efficiency of a single branch is low, the execution needs to be performed twice, which is more inefficient. SUMMARY
[0004] Embodiments of the present application provide a data processing method, device, equipment and storage medium, which can improve query efficiency.
[0005] According to an aspect of the present application, a data processing method is provided, comprising:
[0006] acquiring a set query statement;
[0007] if the set query statement includes two query branches and the two query branches are the same, acquiring a set operation type corresponding to the set query statement;
[0008] rewriting the set query statement according to the set operation type corresponding to the set query statement to obtain a target query statement.
[0009] According to another aspect of the present application, a data processing device is provided, comprising:
[0010] a first acquiring module configured to acquire a set query statement;
[0011] a second acquiring module configured to, if the set query statement includes two query branches and the two query branches are the same, acquire a set operation type corresponding to the set query statement;
[0012] a rewriting module configured to rewrite the set query statement according to the set operation type corresponding to the set query statement to obtain a target query statement.
[0013] According to another aspect of the present application, there is provided an electronic device comprising:
[0014] at least one processor; and
[0015] a memory communicatively connected with the at least one processor; wherein
[0016] the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the data processing method according to any one of the embodiments of the present application.
[0017] According to another aspect of the present application, there is provided a computer readable storage medium storing computer instructions for enabling a processor to implement the data processing method according to any one of the embodiments of the present application when executed by the processor.
[0018] The embodiments of the present application can obtain a set query statement, if the set query statement comprises two query branches and the two query branches are the same, obtain a set operation type corresponding to the set query statement, rewrite the set query statement according to the set operation type corresponding to the set query statement to obtain a target query statement, and can improve the query efficiency.
[0019] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the present application, nor to limit the scope of the present application. Other features of the present application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be regarded as limiting the scope. For those skilled in the art, other related drawings can also be obtained without creative labor.
[0021] Figure 1 is a flow chart of a data processing method in the embodiments of the present application;
[0022] Figure 2 is a flow chart of another data processing method in the embodiments of the present application;
[0023] Figure 3 is a structural schematic diagram of a data processing device in the embodiments of the present application;
[0024] Figure 4 is a structural schematic diagram of an electronic device in the embodiments of the present application. DETAILED DESCRIPTION
[0025] In order to make the person skilled in the art better understand the technical scheme of the present application, the technical scheme in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by the person skilled in the art without creative labor should belong to the protection scope of the present application.
[0026] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to include only those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to the process, method, product or device.
[0027] It can be understood that, before using the technical scheme disclosed in the embodiments of the present application, the type, use range, use scene and the like of the personal information involved in the present application should be informed to the user and the authorization of the user should be obtained according to relevant laws and regulations.
[0028] Embodiment one
[0029] Figure 1 A flowchart of a data processing method provided by the embodiments of the present application, the present embodiment can be applied to the rewriting of a set query statement containing the same query branch. The method can be executed by a data processing device in the embodiments of the present application, and the device can be realized in the form of software and / or hardware. As shown in the figure, the method specifically includes the following steps: Figure 1 The method specifically includes the following steps:
[0030] S110, acquiring a set query statement.
[0031] The set query statement can be a set query statement for performing a union operation, a set query statement for performing an intersection operation, or a set query statement for performing a difference operation.
[0032] S120, if the set query statement includes two query branches and the two query branches are the same, acquiring a set operation type corresponding to the set query statement.
[0033] The two query branches included in the set query statement can be single query statements, for example, the set query statement: select * from t1 union select * from t1, the select * from t1 on the left of the set operator union is the left branch, the select * from t1 on the right of the set operator union is the right branch, and the left branch and the right branch are both single query statements. The two query branches included in the set query statement can be non-single query statements, for example, the set query statement: (select * from t1 union select * from t1) union (select * from t1 union select * from t1), the select * from t1 union select * from t1 on the left of the set operator union is the left branch, the select * from t1 union select * from t1 on the right of the set operator union is the right branch, and the left branch and the right branch are both non-single query statements.
[0034] It should be noted that one of the two query branches included in the set query statement can be a non-single query statement, and one of the two query branches can be a single query statement, and the embodiment of the application does not limit this.
[0035] The determination manner that the two query branches are the same can be that: comparing the element items constituting the two query branches, if the element items constituting the two branches are the same, it is determined that the two query branches are the same. For example, if the left branch is composed of a query item, a FROM item and a grouping item, the right branch is composed of a query item, a FROM item and a grouping item, the query item of the left branch is the same as the query item of the right branch, the FROM item of the left branch is the same as the FROM item of the right branch, and the grouping item of the left branch is the same as the grouping item of the right branch, it is determined that the left branch and the right branch are the same.
[0036] The set operation type includes: union operation, intersection operation and difference set operation.
[0037] Specifically, if the set query statement includes two query branches, and the two query branches are the same, the manner of obtaining the set operation type corresponding to the set query statement can be: if the set query statement includes two query branches, and the two query branches are both single query statements, the element items constituting each query branch are obtained, if the element items constituting each query branch are the same, the set operator in the set query statement is obtained; and the set operation type corresponding to the set query statement is determined according to the set operator in the set query statement.
[0038] S130, rewriting the set query statement according to the set operation type corresponding to the set query statement to obtain a target query statement.
[0039] Specifically, the manner of rewriting the set query statement according to the set operation type corresponding to the set query statement to obtain a target query statement can be: if the set operation type corresponding to the set query statement is a union set operation type and the set operator is UNION, then any query branch after adding a de-duplication item is determined as the target query statement; if the set operation type corresponding to the set query statement is an intersection set operation type and the set operator is INTERSECT, then any query branch after adding a de-duplication item is determined as the target query statement; if the set operation type corresponding to the set query statement is an intersection set operation type and the set operator is INTERSECT ALL, then any query branch is determined as the target query statement; and if the set operation type corresponding to the set query statement is a difference set operation type, then any query branch after replacing a filter condition with a target Boolean expression whose value is FALSE is determined as the target query statement.
[0040] Optionally, rewriting the set query statement according to the set operation type corresponding to the set query statement to obtain a target query statement comprises:
[0041] if the set operation type corresponding to the set query statement is a union set operation type and the set operator is a first operator, then any query branch after adding a de-duplication item is determined as the target query statement;
[0042] if the set operation type corresponding to the set query statement is an intersection set operation type and the set operator is a second operator, then any query branch after adding a de-duplication item is determined as the target query statement;
[0043] if the set operation type corresponding to the set query statement is an intersection set operation type and the set operator is a third operator, then any query branch is determined as the target query statement;
[0044] if the set operation type corresponding to the set query statement is a difference set operation type, then any query branch after replacing a filter condition with a target Boolean expression whose value is FALSE is determined as the target query statement.
[0045] The first operator is UNION, the second operator is INTERSECT, and the third operator is INTERSECT ALL.
[0046] Specifically, if the set operation type corresponding to the set query statement is the union set operation type, and the set operator is the first operator, any query branch after adding the de-duplication item is determined as the target query statement. For example, the set query statement can be: select * from t1 union select * from t1; and the target query statement can be: select distinct * from t1.
[0047] It should be noted that the principle of the UNION ALL operation is to take the union set of the result sets of the left and right query branches without de-duplication. The result set is all records in the result sets of the two query branches, so the two query branches cannot be eliminated by merging.
[0048] Specifically, if the set operation type corresponding to the set query statement is the intersection set operation type, and the set operator is the second operator, any query branch after adding the de-duplication item is determined as the target query statement. For example, the set query statement can be: select * from t1 intersect select * from t1; and the target query statement can be: select distinct * from t1.
[0049] Specifically, if the set operation type corresponding to the set query statement is the intersection set operation type, and the set operator is the third operator, any query branch is determined as the target query statement. For example, the set query statement can be: select * from t1 intersect all select * from t1; and the target query statement can be: select * from t1.
[0050] Specifically, if the set operation type corresponding to the set query statement is the difference set operation type, any query branch in which the filter condition is replaced by the target Boolean expression is determined as the target query statement. For example, the set query statement can be: select * from t1 except all select * from t1; or select * from t1 except select * from t1, and the target query statement can be: select * from t1 where FALSE.
[0051] Optionally, if the set query statement includes two query branches, and the two query branches are the same, the set operation type corresponding to the set query statement is obtained, including:
[0052] If the set query statement includes two query branches, and the two query branches are both single query statements, the element item constituting each query branch is obtained.
[0053] If the element items constituting each query branch are all the same, the set operation type corresponding to the set query statement is obtained.
[0054] The element items include at least one of a query item, a FROM item, a grouping item, and a sorting item.
[0055] Specifically, if the element items constituting each query branch are all the same, the set operation type corresponding to the set query statement can be obtained in the following manner: if the corresponding element items of the two query branches are the same, the set operation type corresponding to the set query statement is obtained.
[0056] Optionally, obtaining the set operation type corresponding to the set query statement comprises:
[0057] Obtaining a set operator in the set query statement.
[0058] Determining the set operation type corresponding to the set query statement according to the set operator in the set query statement.
[0059] The set operator can be any one of UNION, UNION ALL, INTERSECT, INTERSECT ALL, EXCEPT, and EXCEPT ALL.
[0060] Specifically, the set operation type corresponding to the set query statement can be determined in the following manner according to the set operator in the set query statement: if the set operator in the set query statement is UNION or UNION ALL, it is determined that the set operation type corresponding to the set query statement is a union set operation type; if the set operator in the set query statement is INTERSECT or INTERSECT ALL, it is determined that the set operation type corresponding to the set query statement is an intersection set operation type; if the set operator in the set query statement is EXCEPT or EXCEPT ALL, it is determined that the set operation type corresponding to the set query statement is a difference set operation type.
[0061] It should be noted that the meaning of the set operator is basically the same as that of the set operation in mathematics, and the difference lies in that the above several operations in the database will remove duplicate tuples in the result set. If duplicate tuples are allowed in the result set, the ALL keyword should be added for use, such as the set operators UNION ALL, INTERSECT ALL, EXCEPT ALL, and the like.
[0062] Optionally, if the set query statement includes two query branches and the two query branches are the same, obtaining the set operation type corresponding to the set query statement comprises:
[0063] If the set query statement includes two query branches, and there is at least one query branch which is not a single query statement, obtaining the set operation type corresponding to the query branch of the non-single query statement;
[0064] rewriting the query branch of the non-single query statement according to the set operation type corresponding to the query branch of the non-single query statement, until the two rewritten query branches are both single query statements, and obtaining the element item constituting each rewritten query branch;
[0065] If the element items constituting each query branch are all the same, obtaining the set operation type corresponding to the set query statement.
[0066] In one specific example, in the process of performing set operation, the case that the two query branches on both sides of the set operator are equivalent may be encountered, for example: create table t1(c1 int); select*from t1 unionselect*from t1; select*from t1 intersect select*from t1, etc. The conventional method needs to calculate the result sets of the left and right two query branches respectively when actually performing the set operation, and then performs set operation on the two result sets. When the execution efficiency of a single branch is low, the execution needs to be performed twice, which is more inefficient. The embodiment of the present application can calculate the result set of a single query branch only under the premise that the left and right two query branches are equivalent, and obtain the overall operation result, which improves the execution efficiency.
[0067] In another specific example, as shown in Figure 2 The present application provides a method for optimizing the efficiency of set query by eliminating the equivalent query branches on both sides of the set operator in the set query. First, it is considered that two query statements with all the same element items such as query items, FROM items, sorting items, grouping items, etc. are equivalent. On this basis, the following optimization methods are provided for three set operations:
[0068] 1. Union operation (UNION operation and UNION ALL operation)
[0069] The principle of UNION operation is to take the union of the result sets of the left and right two query branches and remove duplicates. Since the two query branches are equivalent, for any result set tuple of any branch, the same tuple can be found in the result set of the other branch, and after removing duplicates in the UNION operation, at most one of the two tuples will be retained. Therefore, when the two query branches of the UNION operation are equivalent, the result set is the same as the result set after removing duplicates of a single branch. For example:
[0070] select * from t1 union select * from t1;
[0071] is equivalent to
[0072] select distinct * from t1;
[0073] The principle of UNION ALL operation is to take the union set of the result sets of the left and right two query branches without deduplication, and the result set is all records in the result sets of the two query branches, so the two query branches cannot be eliminated by merging.
[0074] Processing steps:
[0075] 1) Determine whether the two branches of the union operation are equivalent. If neither branch contains a set operation, i.e., both branches are single query statements, then determine whether the constituent components of the two branch query statements are equivalent, such as query items, FROM items, grouping items, sorting items, etc. Only two query statements with all identical constituent components are considered equivalent. If any branch contains a set operation, recursively determine whether the branches are equivalent and whether they can be merged, i.e., recursively perform steps 1)-3). After each branch is processed, return to the top level until the top-level set operation is merged.
[0076] 2) If the two branches are equivalent, then determine whether the UNION operation is UNION or UNION ALL. UNION requires deduplication of the result set, while taking the union set of the result sets of the two equivalent branch queries and deduplicating it is the same as deduplicating the result set of a single branch query. The two query branches can be merged into a single branch query statement, thereby eliminating the equivalent query branches on both sides. UNION ALL does not perform deduplication, and its result set needs to retain all records of the two branches. Therefore, when the operation is UNION ALL, the two branches cannot be merged.
[0077] 3) When the operation is UNION, replace the left branch with itself. If the query statement originally does not have a DISTINCT attribute, set the DISTINCT attribute. Return the query statement as the merged result.
[0078] 2. Intersection operation (INTERSECT operation and INTERSECT ALL operation)
[0079] The principle of INTERSECT operation is to take the intersection of the result sets of the left and right two query branches and deduplicate. Since the two query branches are equivalent, the intersection of their result sets is the result set of a single query branch after deduplication. For example:
[0080] select*from t1 intersect select*from t1;
[0081] Equivalent to
[0082] SELECT DISTINCT * FROM t1;
[0083] The INTERSECT ALL operation does not require deduplication after intersecting the result sets of the two query branches; its result set is directly equivalent to the result set of a single query branch. For example:
[0084] select*from t1 intersect all select*from t1;
[0085] Equivalent to
[0086] select * from t1;
[0087] Processing steps:
[0088] 1) Consistent with the logic of the union operation, first determine whether the statement is a single query statement. If there is a branch that is not a single query statement, then recursively perform steps 1)-3) on that branch, determine whether the left and right branches of the intersection operation are equivalent and the merging method, and return upwards after processing each branch until the top-level set operation is merged; if both branches are single query statements, then normally execute steps 2) and 3).
[0089] 2) If the two branches are equivalent, further determine whether the intersection operation is an INTERSECT or INTERSECT ALL operation, as the processing differs between the two. An INTERSECT operation requires deduplication of the result set after the intersection, and the merged query statement needs to have the DISTINCT attribute set; while an INTERSECT ALL operation retains all records, does not require deduplication, and the merged query statement is consistent with its left and right branches. If it is an INTERSECT operation and the query statement itself does not contain DISTINCT, then the DISTINCT attribute needs to be set for the query statement in the left branch.
[0090] 3) Replace the left branch of the intersection operation statement with itself and return the replaced query statement.
[0091] 3. Difference operations (EXCEPT operation and EXCEPT ALL operation)
[0092] The principle of the EXCEPT operation is to first remove duplicates from the result sets of the left and right query branches, and then perform the difference operation, that is, to remove tuples that have appeared in the result set of the right branch from the result set of the left branch.
[0093] The difference between EXCEPT ALL operation and EXCEPT operation is that the EXCEPT ALL operation does not need to de-duplicate the result sets of the left and right query branches before directly performing the difference set operation.
[0094] When the left and right query branches are equivalent, the difference set operation result should be the same, both of which are empty sets, regardless of whether de-duplication is needed. For example:
[0095] select * from t1 except all select * from t1;
[0096] Or
[0097] select * from t1 except select * from t1;
[0098] Equivalent to
[0099] select * from t1 where FALSE;
[0100] Processing steps:
[0101] 1) In line with the logic of the union operation, first determine whether the statement is a single query statement. If the branch is not a single query statement, recursively perform steps 1)-3) on the branch. Determine whether the difference set operation left and right branches are equivalent. After processing each branch, return upward until the top-level set operation is completed. If both branches are single query statements, normally execute steps 2) and 3).
[0102] 2) If the two branches are equivalent, construct a Boolean expression with a value of FALSE. Replace the filter condition of the left branch with the Boolean expression. After replacement, the query statement will return an empty set. For example: select * from t1 except select * from t1; is replaced by select * from t1 where false except select * from t1.
[0103] 3) Replace the difference set operation statement with the left branch of the statement, and return the replaced query statement.
[0104] The technical solution of the embodiment obtains a set query statement. If the set query statement includes two query branches and the two query branches are the same, the set operation type corresponding to the set query statement is obtained. The set query statement is rewritten according to the set operation type corresponding to the set query statement to obtain a target query statement, which can improve query efficiency.
[0105] Embodiment two
[0106] Figure 3 A structural schematic diagram of a data processing apparatus provided by an embodiment of the present application is shown. The embodiment can be applied to the case of rewriting a set query statement containing the same query branch. The apparatus can be implemented in the form of software and / or hardware, and can be integrated into any device providing data processing functions, such as a server, a personal computer, a mobile phone, a tablet computer, a wearable device, and the like. Figure 3 As shown, the data processing apparatus specifically includes a first obtaining module 210, a second obtaining module 220, and a rewriting module 230.
[0107] The first obtaining module is configured to obtain a set query statement.
[0108] The second obtaining module is configured to, if the set query statement includes two query branches and the two query branches are the same, obtain a set operation type corresponding to the set query statement.
[0109] The rewriting module is configured to rewrite the set query statement according to the set operation type corresponding to the set query statement, to obtain a target query statement.
[0110] The product described above can execute the method provided by any embodiment of the present application, and has the corresponding function modules and beneficial effects of the execution method.
[0111] The technical solution of the embodiment can obtain a set query statement, if the set query statement includes two query branches and the two query branches are the same, obtain a set operation type corresponding to the set query statement, and rewrite the set query statement according to the set operation type corresponding to the set query statement, to obtain a target query statement, thereby improving the query efficiency.
[0112] Embodiment three
[0113] Figure 4 A structural schematic diagram of an electronic device 10 that can be used to implement embodiments of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smart phones, wearable devices (e.g., headsets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit the implementations of the present application described and / or claimed in this document.
[0114] As shown in FIG. 1, the electronic device 10 includes one or more processors 12, one or more memory devices 14, and one or more communication interfaces 16. The processor(s) 12 can be any suitable processing device (e.g., a processor core, a Figure 4As shown, the electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., communicatively connected to the at least one processor 11, where the memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0115] Various components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc., an output unit 17, such as various types of displays, a speaker, etc., a storage unit 18, such as a magnetic disk, an optical disk, etc., and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.
[0116] The processor 11 can be various general and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as a data processing method.
[0117] In some embodiments, the data processing method can be implemented as a computer program tangibly embodied in a computer readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded onto the RAM 13 and executed by the processor 11, one or more steps of the data processing method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform the data processing method by any other appropriate means, such as by means of firmware.
[0118] The various embodiments of the systems and techniques described above can be implemented in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a load programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0119] Computer programs used to implement the processes of the application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer program, when executed, can cause instructions defined in the flow charts and / or block diagrams to be implemented. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine as a standalone software package and partially on a remote machine or entirely on a remote machine or server.
[0120] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store computer programs for use by or in connection with an instruction execution system, apparatus, or device. Computer-readable storage media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, portable compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0121] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0122] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0123] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. A server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.
[0124] It should be understood that the various forms of flow shown above can be re-ordered, added to, or deleted from without departing from the scope of the present disclosure. For example, the steps recited in the present disclosure can be executed in parallel, executed in sequence, or executed in a different order, as long as the desired results of the present disclosure are achieved, and the present disclosure is not limited herein.
[0125] The specific embodiments described above are not intended to be limiting, and persons skilled in the art will appreciate that various modifications, combinations, sub-combinations and alternatives can be made to the specific embodiments without departing from the spirit and principles of the disclosure. Accordingly, the disclosure is not limited to the specific embodiments described above, but only by the scope of the appended claims.
Claims
1. A data processing method, characterized by, The method comprises the following steps: acquiring a set query statement; if the set query statement comprises two query branches and the two query branches are identical, acquiring a set operation type corresponding to the set query statement; rewriting the set query statement according to the set operation type corresponding to the set query statement to obtain a target query statement; rewriting the set query statement according to the set operation type corresponding to the set query statement to obtain a target query statement comprises: if the set operation type corresponding to the set query statement is a union set operation type and the set operator is a first operator, determining any query branch after adding a de-duplication item as the target query statement; if the set operation type corresponding to the set query statement is an intersection set operation type and the set operator is a second operator, determining any query branch after adding a de-duplication item as the target query statement; if the set operation type corresponding to the set query statement is an intersection set operation type and the set operator is a third operator, determining any query branch as the target query statement; if the set operation type corresponding to the set query statement is a difference set operation type, determining a query branch in which a filter condition is replaced by a target Boolean expression whose value is FALSE as the target query statement, wherein the first operator is UNION, the second operator is INTERSECT, and the third operator is INTERSECT ALL.
2. The method of claim 1, wherein, if the set query statement comprises two query branches and the two query branches are identical, acquiring a set operation type corresponding to the set query statement comprises: if the set query statement comprises two query branches and the two query branches are both single query statements, acquiring element items constituting each query branch; if the element items constituting each query branch are identical, acquiring the set operation type corresponding to the set query statement.
3. The method of claim 1, wherein, acquiring a set operation type corresponding to the set query statement comprises: acquiring a set operator in the set query statement; determining the set operation type corresponding to the set query statement according to the set operator in the set query statement.
4. The method of claim 1, wherein, if the set query statement comprises two query branches and the two query branches are identical, acquiring a set operation type corresponding to the set query statement comprises: if the set query statement comprises two query branches and at least one query branch is not a single query statement, acquiring a set operation type corresponding to a query branch of the non-single query statement; rewriting the query branch of the non-single query statement according to the set operation type corresponding to the query branch of the non-single query statement until the two rewritten query branches are both single query statements, and acquiring element items constituting each rewritten query branch; if the element items constituting each query branch are identical, acquiring the set operation type corresponding to the set query statement.
5. A data processing apparatus, characterized by, The method comprises the following steps: a first acquiring module is configured to acquire a set query statement; a second acquiring module is configured to acquire a set operation type corresponding to the set query statement if the set query statement comprises two query branches and the two query branches are identical. The rewriting module is configured to rewrite the set query statement according to a set operation type corresponding to the set query statement, to obtain a target query statement. The rewriting module is specifically configured to: if the set operation type corresponding to the set query statement is a union set operation type, and the set operator is a first operator, then any query branch after adding a de-duplication item is determined as the target query statement; if the set operation type corresponding to the set query statement is an intersection set operation type, and the set operator is a second operator, then any query branch after adding a de-duplication item is determined as the target query statement; if the set operation type corresponding to the set query statement is an intersection set operation type, and the set operator is a third operator, then any query branch is determined as the target query statement; if the set operation type corresponding to the set query statement is a difference set operation type, then a filter condition is replaced by any query branch of a target Boolean expression, and the query branch is determined as the target query statement, wherein a value of the target Boolean expression is FALSE, the first operator is UNION, the second operator is INTERSECT, and the third operator is INTERSECT ALL.
6. The apparatus of claim 5, wherein, The second obtaining module is specifically configured to: if the set query statement includes two query branches, and both of the two query branches are single query statements, then element items constituting each query branch are obtained; if the element items constituting each query branch are the same, then a set operation type corresponding to the set query statement is obtained.
7. An electronic device, comprising: The electronic device includes: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the data processing method in any one of claims 1-4.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions, and the computer instructions are used to enable the processor to implement the data processing method in any one of claims 1-4 when executed.
Citation Information
Patent Citations
Optimization method and device for data query, and equipment and storage medium
CN110515973A
Method, system and program for executing a query having a union operator
US20060101011A1