Method, device and equipment for reducing data storage amount, medium and product
By judging the optimized scenario of the set operation query statement and delegating the maximum grouping item to the intermediate result set of public expressions, the query performance problem caused by the large amount of data stored in the intermediate result set of public expressions is solved, and the data storage amount is reduced and the query performance is improved.
Patent Information
- Application Number
- CN202411600445.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-03-04
AI Technical Summary
In the prior art, the amount of data stored in the intermediate result set of common expressions is large, resulting in poor query performance.
After obtaining the union set operation query statement, determine whether it is an optimized scenario. If so, the maximum grouping item in the grouping operator is placed in the intermediate result set of the common expression, and the repeated grouping items in the branch are removed to output the intermediate result set of the common expression.
It effectively reduces the data storage amount of the result set in the intermediate common expression, saves the use of memory resources, and improves query performance.
Smart Images

Figure CN119557339A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of data processing technology, and in particular, to a method, device, equipment, medium and product for reducing the amount of data stored. Background Art
[0002] When multiple branches of a union set operation contain the same query part, the optimizer converts the same query part into a common expression intermediate result set, stores the common expression intermediate result set in memory, and obtains the data from the common expression intermediate result set when multiple branches of the union set operation need data.
[0003] This will cause the amount of data stored in the public expression intermediate result set to be large, and the large amount of memory resources used will lead to reduced device performance. Therefore, how to reduce the amount of data in the public expression intermediate result set is a technical problem that needs to be solved urgently. Summary of the invention
[0004] The present invention provides a method, device, equipment, medium and product for reducing the amount of data stored, so as to solve the problem in the prior art that the amount of data stored in the intermediate result set of a common expression is large, resulting in poor query performance.
[0005] According to one aspect of the present invention, there is provided a method for reducing the amount of data storage, comprising:
[0006] After obtaining the union set operation query statement, determining whether the union set operation query statement corresponds to an optimizable scenario;
[0007] If yes, then the maximum grouping items in the grouping operators of each branch in the union set operation query statement are placed in the common expression intermediate result set;
[0008] If there is a grouping item in each branch of the union set operation query statement that is the same as the grouping maximum item, the grouping item is removed from the branch where it is located, and the common expression intermediate result set is output.
[0009] According to another aspect of the present invention, there is provided a device for reducing the amount of data storage, comprising:
[0010] An acquisition module, configured to determine whether the union set operation query statement corresponds to an optimizable scenario after acquiring the union set operation query statement;
[0011] A storage module, for, if yes, placing the maximum grouping item in the grouping operator of each branch in the union set operation query statement into a common expression intermediate result set;
[0012] The output module is used to remove the grouping item from the branch where it is located if there is a grouping item in each branch of the union set operation query statement that is the same as the grouping maximum item, and output the common expression intermediate result set.
[0013] According to another aspect of the present invention, there is provided an electronic device, the electronic device comprising:
[0014] at least one processor;
[0015] and a memory communicatively coupled to the at least one processor;
[0016] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method for reducing the amount of data storage described in any embodiment of the present invention.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for reducing the amount of data storage described in any embodiment of the present invention when executed.
[0018] The technical solution of the embodiment of the present invention determines whether the union set operation query statement corresponds to an optimizable scenario after obtaining the union set operation query statement; if so, the grouping maximum item in the grouping operator of each branch in the union set operation query statement is placed in the common expression intermediate result set; if there is a grouping item in each branch of the union set operation query statement that is the same as the grouping maximum item, the grouping item is removed from the branch where it is located, and the common expression intermediate result set is output, which solves the problem that the query performance is poor due to the large amount of data stored in the common expression intermediate result set, and achieves the beneficial effect of effectively reducing the data storage amount of the common expression intermediate result set, thereby saving the use of memory resources.
[0019] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 A schematic diagram of a flow chart of a method for reducing data storage volume provided in Embodiment 1 of the present invention;
[0022] Figure 2 A flowchart of a method for reducing data storage volume provided in Embodiment 2 of the present invention;
[0023] Figure 3 A schematic diagram of the structure of a device for reducing the amount of data storage provided in Embodiment 3 of the present invention;
[0024] Figure 4 A schematic diagram of the structure of an electronic device for a method of reducing data storage capacity according to an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only an embodiment of a part of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work should belong to the scope of protection of the present invention. It should be understood that the various steps recorded in the method implementation of the present invention can be performed in different orders and / or in parallel. In addition, the method implementation may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.
[0026] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] It should be noted that the modifications of "one" and "plurality" mentioned in the present invention are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0029] The names of the messages or information exchanged between multiple devices in the embodiments of the present invention are only used for illustrative purposes, and are not used to limit the scope of these messages or information.
[0030] Embodiment 1
[0031] Figure 1 A flow chart of a method for reducing data storage volume provided in Embodiment 1 of the present invention is applicable to processing union set operation query statements. The method can be executed by a device for reducing data storage volume, wherein the device can be implemented by software and / or hardware and is generally integrated on an electronic device. In this embodiment, the electronic device includes but is not limited to: computer equipment.
[0032] like Figure 1 As shown, a method for reducing the amount of data storage provided by Embodiment 1 of the present invention includes the following steps:
[0033] S110: After obtaining the union set operation query statement, determine whether the union set operation query statement corresponds to an optimizable scenario.
[0034] Among them, the union set operation is to merge the result sets of two or more SELECT statements and remove duplicate rows. The union operation is usually implemented in SQL using the UNION keyword. UNION will automatically remove duplicate rows. If you want to include duplicate rows, you can use UNION ALL. The union set operation used in this article is UNION ALL.
[0035] In this embodiment, it is possible to determine whether the current scenario is optimizable based on the grouping operations corresponding to each branch in the UNION ALL query statement and the maximum value of the grouping items in the grouping operator. If so, the subsequent optimization operations are continued; if not, the current process is terminated.
[0036] S120: If yes, then put the maximum grouping items in the grouping operators of each branch in the union set operation query statement into the common expression intermediate result set.
[0037] When executing a query in the database, if multiple branches of UNION ALL contain the same query part, the optimizer will convert the common part into a common expression intermediate result set HTAB. As an intermediate result set, it is temporarily stored in the memory and obtained from HTAB when multiple branches of UNION ALL need data.
[0038] In this embodiment, after determining that the scenario can be optimized, the GROUP BY maximum item in the grouping operator of each branch in the union set operation query statement can be placed in the HTAB.
[0039] The maximum group item is the maximum value of the group items in the GROUP operator.
[0040] S130. If there is a grouping item in each branch of the union set operation query statement that is the same as the grouping maximum item, remove the grouping item from the branch where it is located, and output the common expression intermediate result set.
[0041] Exemplarily, if the union set operation query statement has three branches, if there is a grouping item in the first branch that is the same as the grouping maximum item, the grouping item is removed from the first branch, and the common expression intermediate result set HTAB is output.
[0042] A method for reducing the amount of data storage provided by a first embodiment of the present invention comprises the following steps: first, after obtaining a union set operation query statement, determine whether the union set operation query statement corresponds to an optimizable scenario; then, if so, place the maximum grouping item in the grouping operator of each branch in the union set operation query statement into a common expression intermediate result set; finally, if there is a grouping item in each branch of the union set operation query statement that is the same as the maximum grouping item, remove the grouping item from the branch where it is located, and output the common expression intermediate result set. The above method uses the features of the grouping item to extract the maximum grouping item, and places the maximum grouping item into the common expression intermediate result set. On the one hand, it can reduce the size of the common expression intermediate result set and effectively reduce the use of memory resources; on the other hand, due to the reduction in the amount of data in the expression intermediate result set, the input items for grouping based on the operator scanned by the common expression intermediate result set in other branches of the union set operation will also be reduced, thereby improving query performance.
[0043] Based on the above embodiment, a variant embodiment of the above embodiment is proposed. It should be noted that in order to make the description concise, only the differences from the above embodiment are described in the variant embodiment.
[0044] In one embodiment, the optimizable scenario satisfies the following conditions:
[0045] Each branch in the union set operation query statement has a scan based on the same common expression intermediate result set and a group calculation for the scan result;
[0046] The grouping maximum term is a grouping term of a grouping operator in each branch of the union set operation query statement, and the grouping maximum term includes all grouping terms of other grouping operators.
[0047] In this embodiment, a scenario can be determined as an optimizable scenario if the following two conditions are met:
[0048] Condition 1: Each branch in the UNION ALL query has a scan based on the same HTAB and a group calculation after the scan, and there is no other operation between the two.
[0049] Condition 2: The maximum group item in the grouping operator corresponding to the grouping calculation is a grouping operator in each branch, which contains all GROUP BY items of other grouping operators (excluding the constant NULL).
[0050] In one embodiment, the optimizable scenario meets the following conditions:
[0051] Each branch in the union set operation query statement has a scan based on the same common expression intermediate result set and a group calculation for the scan result;
[0052] The maximum grouping term is the union of the grouping terms of all grouping operators in each branch in the union set operation query statement.
[0053] In this embodiment, a scenario can be determined as an optimizable scenario if the following two conditions are met:
[0054] Condition 1: Each branch in the UNION ALL query has a scan based on the same HTAB and a group calculation after the scan, and there is no other operation between the two.
[0055] Condition 2: The maximum grouping term in the grouping operator of each branch of the grouping calculation is the union of the grouping terms of each grouping operator.
[0056] Further, if the grouping items in each branch of the union set operation query statement are different from the grouping maximum item, the grouping items in each branch of the union set operation query statement are kept unchanged.
[0057] Furthermore, the method further includes: grouping and compressing each branch in the union set operation query statement.
[0058] In this embodiment, through the operations of step S110 to step S120, HTAB first performs a compression, and then each UNION ALL branch performs group compression on this basis.
[0059] Among them, each UNION ALL branch performs group compression on this basis, which is a conventional compression step and will not be elaborated here.
[0060] Embodiment 2
[0061] Figure 2 A flowchart of a method for reducing data storage volume provided in Embodiment 2 of the present invention is shown in FIG. Figure 2 As shown, a method for reducing the amount of data storage provided by Embodiment 2 of the present invention includes the following process:
[0062] Determine whether the scenario can be optimized; if it can be optimized, move the GROUP BY maximum item to HTAB, and continue to determine whether the GROUP BY item in each branch is the same as the GROUP BY maximum item; if they are the same, remove the GROUP BY item; if they are different, keep the GROUP BY items of all branches of UNION ALL unchanged; if it is not an optimizeable scenario, end the process.
[0063] The determination of whether a scenario is optimizable includes the following:
[0064] The query statement for the union set operation is the scan of the same HTAB and the group calculation after the scan; obtain the maximum value of the grouping item in the GROUP operator; and determine whether optimization can be performed:
[0065] The GROUP BY maximum item is the grouping item of a grouping operator in each branch of the union set operation query statement. The GROUP BY maximum item includes all the grouping items of other grouping operators or the GROUP BY maximum item is the union of the grouping items of all the grouping operators in each branch of the union set operation query statement.
[0066] A method for reducing data storage volume provided in the second embodiment of the present invention can effectively reduce the data storage volume of the intermediate result set of a common expression, thereby saving the use of memory resources and improving query performance.
[0067] The embodiment of the present invention provides a specific implementation method based on the technical solutions of the above embodiments.
[0068] Before optimization, the three branches of UNION ALL perform group calculations (group by c1, c2, group by c1, and group by 0), and no grouping is performed in HTAB. The corresponding execution statements are as follows:
[0069] CREATE TABLE T1_OPT(C1 INT,C2 INT);
[0070] CREATE TABLE T2_OPT(C1 INT,C2 INT);
[0071] CREATE OR REPLACE VIEW V2_OPT AS SELECT A.C1+B.C2 C2,A.C2C1 FROM T1_OPT A,T2_OPT B WHERE A.C1=B.C1;
[0072] SELECT AVG(B.C1),B.C1 FROM SYSDBA.V2_OPT AS B GROUP BY B.C1,B.C2
[0073] UNION ALL
[0074] SELECT AVG(B.C1),B.C1 FROM SYSDBA.V2_OPT AS B GROUP BY B.C1
[0075] UNION ALL
[0076] SELECT AVG(B.C1),NULL AS"C1"FROM SYSDBA.V2_OPT AS B GROUP BY 0;
[0077] The results are as follows:
[0078]
[0079]
[0080] Among them, HAGR2 is the grouping operator.
[0081] After optimization, the GROUP BY maximum values B.C1 and B.C2 are moved to the HTAB, and the GROUP BY of a branch of UNION ALL is completely removed. The remaining two branches perform their own grouping based on the grouped HTAB.
[0082] The optimized plan is as follows:
[0083]
[0084]
[0085] distinct_flag[0,0]; slave_empty(0)keys(DMTEMPVIEW_889193484.TMPCOL2,DMTEMPVIEW_889193484.TMPCOL3)
[0086] 21 #PRJT2:[1,15,16];exp_num(2),is_atom(FALSE)
[0087] 22#HASH2 INNER JOIN:[1,15,16];KEY_NUM(1);
[0088] KEY(A.C1=B.C1)KEY_NULL_EQU(0)
[0089] 23#CSCN2:[1,3,8];INDEX33556211(T1_OPT as A);btr_scan(1)
[0090] 24#CSCN2:[1,5,8];INDEX33556224(T2_OPT as B);btr_scan(1)
[0091] We can find the union of GROUP BY B.C1 and GROUP BY B.C2, GROUP BY B.C1, B.C2, and we can also put the entire parallel operation into HTAB, and then keep the branches of UNION ALL unchanged. In this way, the storage capacity of HTAB can be reduced.
[0092] Embodiment 3
[0093] Figure 3 A structural schematic diagram of a device for reducing data storage volume provided in Example 3 of the present invention, the device can be applicable to processing union set operation query statements, wherein the device can be implemented by software and / or hardware and is generally integrated on an electronic device.
[0094] like Figure 3 As shown, the device includes: an acquisition module 110 , a storage module 120 and an output module 130 .
[0095] An acquisition module 110 is used to determine whether the union set operation query statement corresponds to an optimizable scenario after acquiring the union set operation query statement;
[0096] Storage module 120, for, if yes, placing the maximum grouping item in the grouping operator of each branch in the union set operation query statement into the common expression intermediate result set;
[0097] The output module 130 is used to remove the grouping item from the branch where it is located if there is a grouping item in each branch of the union set operation query statement that is the same as the grouping maximum item, and output the common expression intermediate result set.
[0098] In this embodiment, the device first obtains the union set operation query statement through the acquisition module 110, and then determines whether the union set operation query statement corresponds to an optimizable scenario; then, if so, the storage module 120 is used to place the grouping maximum item in the grouping operator of each branch in the union set operation query statement into the common expression intermediate result set; finally, the output module 130 is used to remove the grouping item from the branch where it is located if there is a grouping item in each branch of the union set operation query statement that is the same as the grouping maximum item, and output the common expression intermediate result set.
[0099] This embodiment provides a device for reducing the amount of data storage, which can effectively reduce the amount of data storage of the intermediate result set of the common expression, thereby saving the use of memory resources and improving query performance.
[0100] Furthermore, the optimizable scenario satisfies the following conditions:
[0101] Each branch in the union set operation query statement has a scan based on the same common expression intermediate result set and a group calculation for the scan result;
[0102] The grouping maximum term is a grouping term of a grouping operator in each branch of the union set operation query statement, and the grouping maximum term includes all grouping terms of other grouping operators.
[0103] Furthermore, the optimizable scenario satisfies the following conditions:
[0104] Each branch in the union set operation query statement has a scan based on the same common expression intermediate result set and a group calculation for the scan result;
[0105] The maximum grouping term is the union of the grouping terms of all grouping operators in each branch in the union set operation query statement.
[0106] Based on the above technical solution, there is no other operation between executing the scan based on the same common expression intermediate result set and the group calculation for the scan result.
[0107] Furthermore, the device also includes a maintaining module, which is used to: if there are grouping items in each branch of the union set operation query statement that are different from the grouping maximum item, then keep the grouping items in each branch of the union set operation query statement unchanged.
[0108] Furthermore, the device also includes a compression module, which is used to group and compress each branch in the union set operation query statement.
[0109] The above-mentioned device for reducing the amount of data storage can execute the method for reducing the amount of data storage provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0110] Embodiment 4
[0111] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0112] like Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to 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.
[0113] A number of 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, speakers, etc.; a storage unit 18, such as a 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.
[0114] The processor 11 may be a variety of general and / or special 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 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 the various methods and processes described above, such as a method for reducing the amount of data storage.
[0115] In some embodiments, the method for reducing the amount of data storage may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps in the method for reducing the amount of data storage described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the method for reducing the amount of data storage in any other appropriate manner (e.g., by means of firmware).
[0116] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0117] In some embodiments, the method for reducing the amount of data storage can be implemented as a computer program, which is invisibly included in a computer program product. The computer program implements the method for reducing the amount of data storage of the present invention when executed by a processor. The computer program product can be understood as a software product that mainly implements its solution through a computer program. The computer program for implementing the method of the present invention 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, a special-purpose computer, or other programmable data processing device, so that the computer program, when executed by the processor, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The computer program can be executed entirely on the machine, partially on the machine, partially on the machine as an independent software package, and partially on a remote machine, or completely on a remote machine or server.
[0118] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0119] To provide interaction with a user, the systems and techniques described herein may 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 trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0120] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may 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.
[0121] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may 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 difficult management and weak business scalability in traditional physical hosts and VPS services.
[0122] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0123] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for reducing the amount of data storage, characterized in that: The method comprises: After obtaining the union set operation query statement, determining whether the union set operation query statement corresponds to an optimizable scenario; If yes, then the maximum grouping item in the grouping operator of each branch in the union set operation query statement is placed in the common expression intermediate result set; If there is a grouping item in each branch of the union set operation query statement that is the same as the grouping maximum item, the grouping item is removed from the branch where it is located, and the common expression intermediate result set is output.
2. The method according to claim 1, characterized in that The optimizable scenario meets the following conditions: Each branch in the union set operation query statement has a scan based on the same common expression intermediate result set and a group calculation for the scan result; The grouping maximum term is a grouping term of a grouping operator in each branch of the union set operation query statement, and the grouping maximum term includes all grouping terms of other grouping operators.
3. The method according to claim 1, characterized in that The optimizable scenario meets the following conditions: Each branch in the union set operation query statement has a scan based on the same common expression intermediate result set and a group calculation for the scan result; The maximum grouping term is the union of the grouping terms of all grouping operators in each branch in the union set operation query statement.
4. The method according to claim 1, characterized in that: Also includes: If the grouping items in each branch of the union set operation query statement are different from the grouping maximum item, the grouping items in each branch of the union set operation query statement are kept unchanged.
5. The method according to claim 2 or 3, characterized in that: There are no other operations between performing a scan based on the same common expression intermediate result set and performing group calculations on the scan results.
6. The method according to claim 1, characterized in that The method further comprises: Each branch in the union set operation query statement is then grouped and compressed.
7. A device for reducing the amount of data storage, characterized in that: The device comprises: An acquisition module, configured to determine whether the union set operation query statement corresponds to an optimizable scenario after acquiring the union set operation query statement; A storage module, for, if yes, placing the maximum grouping item in the grouping operator of each branch in the union set operation query statement into a common expression intermediate result set; The output module is used to remove the grouping item from the branch where it is located if there is a grouping item in each branch of the union set operation query statement that is the same as the grouping maximum item, and output the common expression intermediate result set.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively coupled to the at least one processor; 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 so that the at least one processor can execute the method for reducing the amount of data storage as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for reducing the amount of data storage according to any one of claims 1 to 6 when executed.
10. A computer program product, characterized in that The computer program product comprises a computer program, which, when executed by a processor, implements the method for reducing the amount of data storage according to any one of claims 1 to 6.