Grouping query method and device, electronic equipment, storage medium and product

By using index scanning and partition aggregation, the problem of ordered grouping of partitioned tables is solved, the performance of grouped queries with large amounts of data is improved, and the intervention of external storage is avoided.

CN120929478APending Publication Date: 2025-11-11SHANGHAI DAMENG DATABASE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511034678.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-25
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

In existing technologies, there is a lack of effective methods for ordered grouping of partitioned tables, which leads to performance limitations when performing large-scale grouping operations, especially when memory is insufficient, requiring the use of external storage and affecting query performance.

Method used

By scanning partitions using indexes based on query statements, an ordered data stream is obtained, and aggregation operations are performed inside and outside the partitions to achieve ordered grouping of the partitioned table.

Benefits of technology

This avoids the memory requirements of hash grouping, effectively utilizes the ordered nature of the index for batch processing, and improves the performance of grouped queries on large amounts of data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120929478A_ABST
    Figure CN120929478A_ABST
Patent Text Reader

Abstract

The invention discloses a grouping query method and device, electronic equipment, a storage medium and a product. The grouping query method comprises the steps that for each partition, the partition is scanned based on an index corresponding to a query statement, a scanning result corresponding to the partition is obtained, and the scanning result comprises data streams ordered according to grouping items; and based on a specified aggregation operation in the query statement, aggregating the scanning results corresponding to the partitions to obtain a query result. According to the technical scheme, the partitions are scanned according to the indexes corresponding to the query statements, and the scanning results of the partitions are aggregated, so that ordered grouping of the partition table is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a group query method, apparatus, electronic device, storage medium, and product. Background Technology

[0002] Grouping queries are a common type of query in the Structured Query Language (SCL) for databases. They are used to group data rows with the same values ​​together, and aggregate functions can be applied to each group to perform summary and statistical operations on the dataset.

[0003] A common grouping operation is hash aggregation, which is convenient and simple, but it requires a lot of memory when handling large amounts of data. When memory is insufficient, external storage such as disk is often needed, which greatly impacts query performance. For grouping large amounts of data, if the grouped data can be guaranteed to be strictly ordered according to the grouping key (sorted before grouping or indexed on the grouping key), then sorted aggregation is preferred. This is because rows of data in the same group are continuous in the input data stream, so the data in the current group can be directly aggregated until the next group appears. Sort aggregation does not require the intervention of external storage such as disk, but the requirement that the grouping key must be strictly ordered limits the effectiveness of this method on partitioned tables. Since partitioned tables are built on sub-tables, they cannot be sorted by key, and therefore cannot satisfy the strict ordering requirement for sorted aggregation. Due to these limitations, there is currently no effective sorted aggregation scheme for partitioned tables. Summary of the Invention

[0004] This application provides a grouping query method, apparatus, electronic device, storage medium, and product to achieve ordered grouping of partitioned tables.

[0005] In a first aspect, embodiments of this application provide a grouped query method, including:

[0006] For each partition, the partition is scanned based on the index corresponding to the query statement to obtain the scan result for the partition. The scan result includes a data stream ordered by grouping items.

[0007] Based on the specified aggregation operation in the query statement, the scan results corresponding to each partition are aggregated to obtain the query results.

[0008] Secondly, embodiments of this application also provide a group query device, including:

[0009] The scanning module is used to scan each partition based on the index corresponding to the query statement to obtain the scan result corresponding to the partition. The scan result includes a data stream ordered by grouping items.

[0010] The query module is used to aggregate the scan results corresponding to each partition based on the specified aggregation operation in the query statement to obtain the query results.

[0011] Thirdly, embodiments of this application provide an electronic device, including:

[0012] One or more processors;

[0013] Storage device for storing one or more programs;

[0014] When the one or more programs are executed by the one or more processors, the one or more processors implement the grouped query method as described in the first aspect.

[0015] Fourthly, embodiments of this application also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the grouping query method as described in the first aspect.

[0016] Fifthly, embodiments of this application also provide a computer program product, including a computer program and / or instructions, which, when executed by a processor, implement the grouping query method as described in any of the above embodiments.

[0017] This application provides a grouping query method, apparatus, electronic device, storage medium, and product. The grouping query method includes: for each partition, scanning the partition based on the index corresponding to the query statement to obtain a scan result corresponding to the partition, the scan result including an ordered data stream by grouping items; and aggregating the scan results corresponding to each partition based on a specified aggregation operation in the query statement to obtain a query result. The above technical solution achieves ordered grouping of a partitioned table by scanning partitions according to the index corresponding to the query statement and aggregating the scan results of each partition. Attached Figure Description

[0018] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.

[0019] Figure 1 A flowchart illustrating a grouping query method provided in this application embodiment;

[0020] Figure 2A flowchart illustrating another grouping query method provided in this application embodiment;

[0021] Figure 3 This is a schematic diagram of the structure of a group query device provided in an embodiment of this application;

[0022] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0023] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the application and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present application, not the entire structure.

[0024] Before discussing the exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the steps as sequential processes, many of these steps can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the steps can be rearranged. The process can be terminated when its operation is complete, but may also have additional steps not included in the figures. The process can correspond to a method, function, procedure, subroutine, subroutine, etc.

[0025] It should be noted that the concepts of "first" and "second" mentioned in the embodiments of this application are only used to distinguish different devices, modules, units or other objects, and are not used to limit the order of functions performed by these devices, modules, units or other objects or their interdependencies.

[0026] Furthermore, the embodiments and features described herein can be combined with each other, unless otherwise specified.

[0027] The acquisition, storage, use, and processing of data in this application all comply with the relevant provisions of national laws and regulations.

[0028] It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned. These should be regarded as exemplary and are only intended to illustrate the feasibility of implementing the technical solution of this application. However, it does not mean that the applicant has used or necessarily used the relevant content of the solution.

[0029] Figure 1This is a flowchart illustrating a grouped query method provided in an embodiment of this application. This embodiment is applicable to querying data within a table partition. Specifically, the grouped query method can be executed by a grouped query device, which can be implemented in software and / or hardware and integrated into an electronic device. The electronic device includes, but is not limited to, devices with computing capabilities such as computers, smartphones, or servers, and can also be a Central Processing Unit (CPU), System-on-Chips (SoC) computer, Field-Programmable Gate Array (FPGA), or Micro Controller Unit (MCU), etc.

[0030] like Figure 1 As shown, the method specifically includes the following steps:

[0031] S110. For each partition, scan the partition based on the index corresponding to the query statement to obtain the scan result corresponding to the partition. The scan result includes a data stream ordered by grouping items.

[0032] Specifically, partitioning can be understood as dividing the data of a table into blocks. A table can typically be divided into at least two partitions, and a partition can also be understood as a sub-table. The query statement mainly refers to the grouping query statement in Structured Query Language (SQL), used to group the data of each partition according to certain rules. This process can execute aggregate functions on each group, such as summation (SUM), counting (COUNT), averaging (AVG), finding the maximum value (MAX), and / or finding the minimum value (MIN). The query statement can specify at least one index, or the optimizer can determine at least one index by analyzing the query statement. Based on the index corresponding to the query statement, each partition can be scanned to find the required data for subsequent aggregation processing. The grouping item can be understood as the key used for grouping, i.e., the grouping key value. The scan results (i.e., the required data found) are arranged in order according to the grouping items.

[0033] S120. Based on the specified aggregation operation in the query statement, aggregate the scan results corresponding to each partition to obtain the query result.

[0034] Specifically, the aggregation operation specified in the query statement can be summation, counting, averaging, finding the maximum or minimum value, etc. Based on the aggregation operation specified in the query statement, the scan results of each partition can be aggregated to obtain the final query result. It can be understood that during the aggregation process, each partition can first undergo intra-partition aggregation (i.e., ordered grouping within the partition). This process can be understood as first-level aggregation or primary aggregation, ensuring that the grouping structure within each partition is also an ordered data flow based on the grouping items. Then, the results of the first-level aggregation of each partition are further aggregated, i.e., second-level aggregation or secondary aggregation.

[0035] The present application provides a grouping query method. If the index corresponding to the query statement meets the optimization conditions, the scan results of each partition can be aggregated after scanning the partition, avoiding the memory space requirements of hash grouping. When the grouping key values ​​of each partition are strictly ordered, it can also be considered to meet the condition of ordered grouping, thus realizing ordered grouping of the partition table.

[0036] In one embodiment, the query statement includes a GROUP BY clause, and the grouping item of the GROUP BY clause refers to the leading column of the index; the index is an index determined by the optimizer through analysis of the query statement.

[0037] In this context, the leading column can be understood as the first column of the composite index or a series of consecutive columns starting from the first column. For example, if index IDX1 is created on columns x, y, and z of table T1, then the leading columns of index IDX1 can be x, xy, and xyz, while y, z, and yz are not the leading columns of index IDX1. It is important to note that the method in this embodiment can be used for partitioned tables and is applicable when the grouping key is a leading column of an index on the table. In this case, it can be guaranteed that the data obtained by scanning according to this index is ordered according to the grouping items.

[0038] In one embodiment, based on the specified aggregation operation in the query statement, the scan results corresponding to each partition are aggregated to obtain the query results, including:

[0039] Based on the specified aggregation operation, a first-level aggregation operation is performed on each scan result to obtain the grouping corresponding to each scan result. Each group includes a data stream ordered by the grouping item.

[0040] Perform secondary aggregation operations on the same groups in each partition to obtain the query results.

[0041] For example, in the actual aggregation process, firstly, each partition is subjected to first-level aggregation (i.e., ordered grouping within the partition), and then the aggregation results of each partition are subjected to second-level aggregation. The specified aggregation operation, first-level aggregation operation, and second-level aggregation operation have a corresponding relationship; that is, the first-level and second-level aggregation operations can be determined based on the specified aggregation operation.

[0042] For example, such as Figure 2 As shown, the method may include the following steps:

[0043] S210. For each partition, scan the partition based on the index corresponding to the query statement to obtain the scan result for the partition. The scan result includes a data stream ordered by grouping items.

[0044] S220. Based on the specified aggregation operation, perform a first-level aggregation operation on each of the scan results to obtain groups corresponding to each scan result. Each group includes a data stream ordered by the grouping items.

[0045] S230. Perform a second-level aggregation operation on the same groups in each partition to obtain the query results.

[0046] In one embodiment, the correspondence between specified aggregation operations, first-level aggregation operations, and second-level aggregation operations is shown in Table 1.

[0047] Table 1 specifies the correspondence between aggregation operations, first-level aggregation operations, and second-level aggregation operations.

[0048]

[0049] According to Table 1, when the specified aggregation operation is counting (COUNT), the first-level aggregation operation is counting, and the second-level aggregation operation is summing (SUM); when the specified aggregation operation is summing, the first-level aggregation operation is summing, and the second-level aggregation operation is summing; when the specified aggregation operation is minimizing (MIN), the first-level aggregation operation is minimizing, and the second-level aggregation operation is minimizing; when the specified aggregation operation is maximizing (MAX), the first-level aggregation operation is maximizing, and the second-level aggregation operation is maximizing; when the specified aggregation operation is averaging (AVG), the first-level aggregation operation includes calculating the summation result and the counting result (calculating SUM and COUNT respectively), and the second-level aggregation operation includes summing the summation result (SUM(SUM)), summing the counting result (SUM(COUNT)), and dividing the sum of the summation results by the sum of the counting results (SUM(SUM) / SUM(COUNT)).

[0050] The grouping query method of this application can optimize the grouping query process for query statements that meet certain conditions. As an example, the grouping query method includes:

[0051] Step 1) For the SQL query statement entered by the user, check if the following conditions are met: the query statement contains a group by clause, and the group by item is the leading column of an index on the partitioned table. If this condition is not met, exit optimization; otherwise, proceed to step 2).

[0052] Step 2) For each sub-table partition, scan the data using the index described in Step 1) to obtain an ordered data stream by grouping item, and then execute Step 3);

[0053] Step 3) Group the scan results of each partition in Step 2) in an ordered manner and aggregate them according to the corresponding operations in Table 1. The grouping results of each partition will also be ordered according to the grouping items. Then proceed to Step 4).

[0054] Step 4) Following the corresponding operations in Table 1, perform a second aggregation of the aggregation results of the same groups in each partition in Step 3) using a multi-way merge method to obtain the final result.

[0055] The following example illustrates the grouped query method.

[0056] For example, the grouping query process includes:

[0057] First, create a partitioned table and its indexes that meet the criteria, for example:

[0058] create table t1(c1 int,c2 int,c3 int)partition by range(c1) (

[0060] partition p1 values ​​less than(5),

[0061] partition p2 values ​​less than (maxvalue) );

[0063] create index i1 on t1(c2,c3,c1);

[0064] Based on this, the data in table t1 can be constructed as shown in Table 2.

[0065] Data in Table 2t1

[0066]

[0067] Suppose the following query is executed:

[0068] select c2,c3,sum(c1)from t1 where c1<9group by t1.c2,t1.c3

[0069] The group by terms t1.c2 and t1.c3 are the leading columns of index i1 on partition table t1, which meet the optimization conditions. Therefore, the group query method in this application embodiment can be used.

[0070] The data is stored in index i1 in ascending order of c2, c3, c1. Therefore, a direct index scan will yield the results shown in Tables 3 and 4. The row where C1 = 9 will be discarded because it does not meet the filtering condition c1 < 9.

[0071] The scan results of the sub-indexes of Table 3i1 on partition P1

[0072] C2 C3 C1 1 1 2 1 1 1 2 1 4 2 2 3

[0073] The scan results of the sub-indexes of Table 4i1 on partition P2

[0074] C2 C3 C1 1 1 8 1 2 7 2 2 6 2 2 5

[0075] Because the scan results are ordered according to C2, C3, C1, columns with the same (C2, C3) must be consecutive in the above results. We can use ordered grouping for fast calculation. Based on the correspondence in Table 1, we determine the first-level aggregation as SUM operation, and we can get the results shown in Tables 5 and 6.

[0076] Table 5 shows the results of aggregating data rows where C2 and C3 values ​​are identical using ordered grouping in partitioning P1.

[0077] C2 C3 SUM(C1) 1 1 3(2+1) 2 1 4 2 2 3

[0078] Table 6 shows the results of aggregating data rows with identical C2 and C3 values ​​using ordered grouping for P2 partitioning.

[0079] C2 C3 SUM(C1) 1 1 8 1 2 7 2 2 11(6+5)

[0080] The two results obtained from partitions P1 and P2 are aggregated and summarized in a second time. Based on the relationship in Table 1, the second-level aggregation is determined to be a SUM operation. The final query results are shown in Table 7.

[0081] Table 7 shows the query results obtained after summarizing the results from both P1 and P2.

[0082] C2 C3 SUM(C1) 1 1 11(3+8) 1 2 7 2 1 4 2 2 14(3+11)

[0083] The grouping query method provided in this application can avoid the memory space requirements of hash grouping under large data volume by grouping and aggregating the partitioned table, and can effectively utilize the index ordering to process the data in batches and then summarize it.

[0084] Figure 3 This is a schematic diagram of the structure of a group query device provided in an embodiment of this application. The group query device provided in this embodiment includes:

[0085] Scanning module 310 is used to scan each partition based on the index corresponding to the query statement to obtain the scan result corresponding to the partition, the scan result including a data stream ordered by grouping items;

[0086] The query module 320 is used to aggregate the scan results corresponding to each partition based on the specified aggregation operation in the query statement to obtain the query results.

[0087] This device achieves ordered grouping of partitioned tables by scanning partitions according to the index corresponding to the query statement and aggregating the scan results of each partition.

[0088] Based on any of the above embodiments, the query statement includes a grouping summary clause, and the grouping item of the grouping summary clause is the leading column of the index.

[0089] Based on any of the above embodiments, the query module 320 includes:

[0090] The first aggregation unit is used to perform a first-level aggregation operation on each of the scan results based on the specified aggregation operation, to obtain a group corresponding to each scan result, and each group includes a data stream ordered by the grouping item;

[0091] The second aggregation unit is used to perform secondary aggregation operations on the same groups in each partition to obtain the query results.

[0092] Based on any of the above embodiments, when the specified aggregation operation is counting, the first-level aggregation operation is counting, and the second-level aggregation operation is summing;

[0093] If the specified aggregation operation is summation, and the first-level aggregation operation is summation, then the second-level aggregation operation is summation;

[0094] When the specified aggregation operation is to take the minimum value, and the first-level aggregation operation is to take the minimum value, the second-level aggregation operation is to take the minimum value;

[0095] If the specified aggregation operation is to take the maximum value, and the first-level aggregation operation is to take the maximum value, then the second-level aggregation operation is to take the maximum value.

[0096] When the specified aggregation operation is to take the average, the first-level aggregation operation includes calculating the summation result and the counting result respectively, and the second-level aggregation operation includes summing the summation result, summing the counting result, and dividing the sum of the summation result by the sum of the counting result.

[0097] The group query device provided in this application embodiment can be used to execute the group query method provided in any of the above embodiments, and has corresponding functions and beneficial effects.

[0098] Figure 4 A schematic diagram of an electronic device 10, which can be used to implement embodiments of this application, is shown. The electronic device 10 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 10 may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, user equipment, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the application described and / or claimed herein.

[0099] like Figure 4 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0100] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks and wireless networks.

[0101] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of 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 suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above.

[0102] In some embodiments, the methods described above can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the methods described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the methods of any of the embodiments described above by any other suitable means (e.g., by means of firmware).

[0103] Various embodiments 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-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0104] Computer programs used to implement the methods of this application may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0105] In the context of this application, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium can be, but is 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 machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0106] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0107] This application also provides a computer program product, including a computer program and / or instructions, which, when executed by a processor, implement the group query method as described in any of the above embodiments.

[0108] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this application can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this application can be achieved, and this is not limited herein.

[0109] The specific embodiments described above do not constitute a limitation on the scope of protection of this application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the scope of protection of this application.

Claims

1. A grouped query method, characterized in that, include: For each partition, the partition is scanned based on the index corresponding to the query statement to obtain the scan result for the partition. The scan result includes a data stream ordered by grouping items. Based on the specified aggregation operation in the query statement, the scan results corresponding to each partition are aggregated to obtain the query results.

2. The method according to claim 1, characterized in that, The query statement contains a grouping summary clause, and the grouping item of the grouping summary clause is the leading column of the index; The index is determined by the optimizer through analysis of the query statement.

3. The method according to claim 1, characterized in that, Based on the specified aggregation operation in the query statement, the scan results corresponding to each partition are aggregated to obtain the query results, including: Based on the specified aggregation operation, a first-level aggregation operation is performed on each of the scan results to obtain the groupings corresponding to each scan result. Each group includes a data stream ordered by the grouping items. Perform secondary aggregation operations on the same groups in each partition to obtain the query results.

4. The method according to claim 3, characterized in that, When the specified aggregation operation is counting, the first-level aggregation operation is counting, and the second-level aggregation operation is summing; When the specified aggregation operation is summation, the first-level aggregation operation is summation, and the second-level aggregation operation is summation; When the specified aggregation operation is to take the minimum value, the first-level aggregation operation is to take the minimum value, and the second-level aggregation operation is to take the minimum value; The specified aggregation operation is to take the maximum value, the first-level aggregation operation is to take the maximum value, and the second-level aggregation operation is to take the maximum value; When the specified aggregation operation is to take the average, the first-level aggregation operation includes calculating the summation result and the counting result respectively, and the second-level aggregation operation includes summing the summation result, summing the counting result, and dividing the sum of the summation result by the sum of the counting result.

5. A group query device, characterized in that, include: The scanning module is used to scan each partition based on the index corresponding to the query statement to obtain the scan result corresponding to the partition. The scan result includes a data stream ordered by grouping items. The query module is used to aggregate the scan results corresponding to each partition based on the specified aggregation operation in the query statement to obtain the query results.

6. The apparatus according to claim 5, characterized in that, The query statement contains a grouping summary clause, and the grouping item of the grouping summary clause is the leading column of the index; The index is determined by the optimizer through analysis of the query statement.

7. The apparatus according to claim 5, characterized in that, The query module is specifically used for: Based on the specified aggregation operation, a first-level aggregation operation is performed on each of the scan results to obtain the groupings corresponding to each scan result. Each group includes a data stream ordered by the grouping items. Perform secondary aggregation operations on the same groups in each partition to obtain the query results.

8. An electronic device, characterized in that, include: At least one processor; A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the group query method as described in any one of claims 1-4.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the grouped query method as described in any one of claims 1-4.

10. A computer program product comprising a computer program and / or instructions, characterized in that, When the computer program and / or instructions are executed by the processor, they implement the group query method as described in any one of claims 1-4.