Data table processing method and apparatus of distributed database, electronic device, computer readable storage medium, and computer program product

By performing partial replication, partial redistribution and partial unchanged operations of data tables in a distributed database, the problem of data skew is solved, data processing efficiency is improved, data skew is avoided, and query efficiency is improved.

WO2024222244A1PCT designated stage expired Publication Date: 2024-10-31TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/081004
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-04-25
Filing Date
2024-03-11
Publication Date
2024-10-31

AI Technical Summary

Technical Problem

The data skew problem in distributed databases causes certain nodes to process excessive amounts of data, which in turn results in slow overall processing. Existing technologies lack effective solutions.

Method used

By obtaining the data distribution of the data table to be connected, partial copying, partial redistribution and partial unchanged operations are performed to ensure that the data is evenly distributed among multiple nodes and to avoid data skew.

Benefits of technology

It improves data processing efficiency, avoids data skew problems caused by data copying to the same node, and improves query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024081004_31102024_PF_FP_ABST
    Figure CN2024081004_31102024_PF_FP_ABST
Patent Text Reader

Abstract

The present application provides a data table processing method and apparatus of a distributed database, a device, and a storage medium. The distributed database comprises a plurality of nodes. The method comprises: obtaining a first data table and a second data table that are to be connected in a distributed database, wherein first data in the first data table and second data in the second data table are distributed and stored into the plurality of nodes; obtaining a first data distribution of the first data in the first data table and a second data distribution of the second data in the second data table; on the basis of the first data distribution and the second data distribution, performing partial replication, partial redistribution, and partial keeping-unchanged operations on full data composed of the first data and the second data to obtain operated first data and operated second data correspondingly; and performing a connection operation on the operated first data and the operated second data to obtain a connection result.
Need to check novelty before this filing date? Find Prior Art

Description

Method, device, electronic device, computer-readable storage medium, and computer program product for processing data tables in a distributed database

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application is based on the Chinese patent application with application number 2023104733956 and application date of April 25, 2023, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby introduced into this application as a reference. Technical Field

[0003] The present application relates to the field of data processing and database technology, and in particular to a method, device, electronic device, computer-readable storage medium, and computer program product for processing a data table of a distributed database. Background Art

[0004] Distributed databases usually use smaller computer systems. Each computer (also called a node) can be placed in a separate place. Each computer may have a complete copy or a partial copy of the database management system (DBMS) and its own local database. Many computers located in different locations are interconnected through a network to form a complete, global, logically centralized, and physically distributed large database.

[0005] Data skew is a challenge in distributed databases. Under specific data distribution conditions, data skew can cause certain nodes in the distributed database to process hundreds or even thousands of times more data than other nodes, slowing down overall processing.

[0006] However, there is no effective solution in related technologies for solving the data skew problem in distributed databases.

[0007] Summary of the Invention

[0008] The embodiments of the present application provide a data table processing method, device, electronic device, computer-readable storage medium and computer program product for a distributed database, which can solve the problem of data skew and thereby improve data processing efficiency.

[0009] The technical solution of the embodiment of the present application is implemented as follows:

[0010] An embodiment of the present application provides a data table processing method for a distributed database, which is executed by an electronic device, wherein the distributed database includes multiple nodes; the method includes:

[0011] Acquire a first data table and a second data table to be connected in the distributed database, wherein the first data in the first data table and the second data in the second data table are dispersedly stored in the plurality of nodes;

[0012] Obtain a first data distribution of the first data in the first data table, and a second data distribution of the second data in the second data table;

[0013] Based on the first data distribution and the second data distribution, performing partial copying, partial redistribution, and partial unchanged operations on the full data consisting of the first data and the second data to obtain corresponding first data after the operation and second data after the operation;

[0014] A connection operation is performed on the operated first data and the operated second data to obtain a connection result.

[0015] An embodiment of the present application provides a data table processing device for a distributed database, wherein the distributed database includes a plurality of nodes; including:

[0016] An acquisition module is configured to acquire a first data table and a second data table to be connected in the distributed database, wherein the first data in the first data table and the second data in the second data table are dispersedly stored in the plurality of nodes;

[0017] The acquisition module is further configured to acquire a first data distribution of the first data in the first data table and a second data distribution of the second data in the second data table;

[0018] an operation module configured to perform operations of partially copying, partially redistributing, and partially keeping unchanged on the full data consisting of the first data and the second data based on the first data distribution and the second data distribution, to obtain corresponding first data after the operation and second data after the operation;

[0019] The connection module is configured to perform a connection operation on the first data after the operation and the second data after the operation to obtain a connection result.

[0020] An embodiment of the present application provides an electronic device, including:

[0021] a memory for storing executable instructions;

[0022] The processor is used to implement the data table processing method of the distributed database provided in the embodiment of the present application when executing the executable instructions stored in the memory.

[0023] An embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions for implementing a data table processing method for a distributed database provided in an embodiment of the present application when executed by a processor.

[0024] An embodiment of the present application provides a computer program product, including a computer program or computer executable instructions, which, when executed by a processor, implements the data table processing method of the distributed database provided in the embodiment of the present application.

[0025] The embodiments of the present application have the following beneficial effects:

[0026] For the first data table and the second data table to be connected in the distributed database, based on the first data distribution of the first data in the first data table and the second data distribution of the second data in the second data table, partial replication, partial redistribution and partial unchanged operations are performed on the full data composed of the first data and the second data. In this way, compared with the related art that only uses redistribution or replication when redistributing the full data, the technical solution provided by the embodiment of the present application uses partial replication, partial redistribution and partial unchanged operations to redistribute the full data according to different data distribution methods, so that the full data after the operation is basically evenly distributed in multiple nodes, avoiding the data skew problem caused by copying a large amount of data to the same node when redistributing the full data in the related art, thereby improving data processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] FIG1 is a schematic diagram of the architecture of a data table processing system 100 of a distributed database provided in an embodiment of the present application;

[0028] FIG2 is a schematic structural diagram of an electronic device 600 provided in an embodiment of the present application;

[0029] 3 is a schematic diagram of a flow chart of a data table processing method of a distributed database provided in an embodiment of the present application;

[0030] FIG4 is a flow chart of a method for processing a data table in a distributed database according to an embodiment of the present application;

[0031] FIG5 is a schematic diagram showing the corresponding relationship between execution time and data skew provided in an embodiment of the present application;

[0032] FIG6 is a schematic diagram showing the principle of a data table processing method for a distributed database provided by a related art;

[0033] 7 is a schematic diagram showing the principles of a data table processing method for a distributed database provided in an embodiment of the present application;

[0034] FIG8 is a schematic diagram showing the principle of a data table processing method for a distributed database provided in an embodiment of the present application;

[0035] FIG9 is a schematic diagram showing the principle of a data table processing method for a distributed database provided by a related art;

[0036] FIG10 is a schematic diagram showing the principle of a data table processing method for a distributed database provided in an embodiment of the present application;

[0037] FIG11 is a schematic diagram showing the principle of a data table processing method for a distributed database provided in an embodiment of the present application;

[0038] FIG12 is a schematic diagram showing the principle of a data table processing method for a distributed database provided in an embodiment of the present application;

[0039] FIG13 is a schematic diagram showing the principle of a data table processing method for a distributed database provided in an embodiment of the present application;

[0040] FIG14 is a schematic diagram showing a comparison of effects provided by an embodiment of the present application. DETAILED DESCRIPTION

[0041] In order to make the purpose, technical solutions and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limiting this application. All other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0042] In the following description, reference is made to “some embodiments”, which describes a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0043] It is understandable that in the embodiments of the present application, when user information and other related data are involved, when the embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0044] In the following description, the terms "first\second\..." are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It is understandable that "first\second\..." can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0045] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0046] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meaning as commonly understood by those skilled in the art of the present application. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the embodiments of the present application.

[0047] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.

[0048] 1) Distribution Key: A column (or set of columns) that determines the database partition where a particular row of data is stored. The column used as the query condition is typically selected as the distribution key, allowing for node pruning based on the distribution key. If no distribution key is specified when creating a table, the primary key of the table is used as the distribution key by default. If the table does not have a primary key, the first column is used as the distribution key by default.

[0049] 2) Join key: A key used to connect data in two data tables. For example, for an order table and an order details table, the order ID can be used as the join key to connect the order data in the two tables.

[0050] 3) Data table: It is the basic unit for organizing data in a distributed database. A distributed database can include multiple data tables.

[0051] 4) In response to: used to indicate the conditions or states on which the executed operations depend. When the dependent conditions or states are met, one or more operations executed can be in real time or with a set delay. Unless otherwise specified, there is no restriction on the order in which the multiple operations executed are executed.

[0052] 5) Data skew: In a distributed database, due to uneven data distribution, some nodes process too much data.

[0053] 6) Distributed Database (DDB): refers to a system of smaller computers, each of which can be placed in a separate place. Each computer may have a complete copy or a partial copy of the database management system (DBMS) and its own local database. Many computers in different locations can be connected to each other through the network to form a complete, global, logically centralized, and physically distributed large database.

[0054] 7) Data Table: It is a grid virtual table that temporarily stores data (representing a table of data in memory). The data table is the core object in the database. It can be simply bound to the database without any code and can be used to store specific data.

[0055] Data skew is a challenge for distributed databases. Under certain data distribution conditions, data skew can cause certain nodes in the distributed database to process hundreds or even thousands of times more data than other nodes, slowing down overall processing. Furthermore, there are many reasons for data skew, including the following: the data in the table itself is unevenly distributed, resulting in skew; there are high-frequency values ​​corresponding to the distribution key or join key; data skew is caused by data associations after data joins or grouping; and data skew is caused by specific predicates, such as equivalence conditions. Furthermore, data skew can have the following serious consequences: long-tail phenomena, such as a node not being completed, slowing down the entire query; insufficient resources on a single node, while other nodes have no data to process; significant query bottlenecks, resulting in significant resource consumption; and insufficient content on certain nodes, causing the entire query to fail.

[0056] In view of this, the embodiments of the present application provide a data table processing method, device, electronic device, computer-readable storage medium and computer program product for a distributed database, which can solve the problem of data skew and thus improve data processing efficiency. The electronic device provided by the embodiments of the present application is described below. The electronic device provided by the embodiments of the present application can be implemented as a server, or can be implemented in collaboration with a terminal device and a server. The following is an example of a data table processing method for a distributed database provided by an embodiment of the present application being implemented in collaboration with a terminal device and a server.

[0057] For example, see Figure 1, which is a schematic diagram of the architecture of a data table processing system 100 of a distributed database provided in an embodiment of the present application. In order to support the solution of data skew problems and improve data processing efficiency, as shown in Figure 1, the data table processing system 100 of a distributed database includes: a server 200, a network 300, a terminal device 400, and a distributed database 500, wherein the network 300 can be a local area network or a wide area network, or a combination of the two, the terminal device 400 is a user-associated terminal device, and a client 410 runs on the terminal device 400. The client 410 can be various types of clients, such as database applications, data table applications, browsers, etc. The distributed database 500 includes multiple nodes, such as node 510, node 520, node 530, etc.

[0058] In some embodiments, when a user needs to connect two data tables in the distributed database 500, the user can enter the identifiers corresponding to the two data tables (such as the name and number of the data tables) in the human-computer interaction interface of the client 410. After receiving the identifier of the data table input by the user, the client 410 can send the received identifier of the data table to the server 200 through the network 300, so that the server 200 can obtain the first data table (such as data table A) and the second data table (such as data table B) corresponding to the identifier of the data table from the distributed database 500 based on the received identifier of the data table. Then, the server 200 can also obtain the first data distribution of the first data in the first data table (for example, whether the distribution key of the first data table is a connection key, the connection key, etc.). The server 200 may determine whether the data corresponding to the key in the first data table includes high-frequency data, etc., and the second data distribution of the second data in the second data table (for example, whether the distribution key of the second data table is a connection key, whether the data corresponding to the connection key in the second data table includes high-frequency data, etc.). Subsequently, the server 200 may perform partial replication, partial redistribution, and partial unchanged operations on the full amount of data consisting of the first data in the first data table and the second data in the second data table based on the first data distribution and the second data distribution. Finally, the server 200 performs a connection operation on the operated first data and the operated second data to obtain a connection result, and returns the connection result to the terminal device 400 through the network 300, so that the terminal device 400 calls the human-computer interaction interface of the client 410 for presentation.

[0059] It should be noted that the data table processing method of the distributed database provided in the embodiment of the present application can also be implemented by a distributed database. For example, when connecting the first data table and the second data table, the data redistribution operation and the connection operation can be realized through the underlying capabilities of the distributed database. The embodiment of the present application does not make specific limitations on this.

[0060] In other embodiments, the embodiments of the present application can also be implemented with the help of cloud technology. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and network within a wide area network or local area network to realize data calculation, storage, processing, and sharing.

[0061] Cloud technology is a general term for network, information, integration, management platform, and application technologies used in the cloud computing business model. It can form a resource pool that can be used flexibly and conveniently on demand. Cloud computing technology will become a key support. The backend services of technical network systems require a large amount of computing and storage resources.

[0062] For example, the server 200 in Figure 1 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDNs), and big data and artificial intelligence platforms. The terminal device 400 can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a car terminal, etc., but is not limited to this. The terminal device 400 and the server 200 can be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present application.

[0063] In some embodiments, the data table processing method of the distributed database provided in the embodiments of the present application can also be implemented with the help of blockchain technology. For example, the first data in the first data table and the second data in the second data table can be stored in different nodes of the blockchain network in a distributed manner. Based on the tamper-proof nature of the blockchain, the security of the data can be guaranteed.

[0064] The structure of the electronic device provided by the embodiment of the present application will be described below. Taking the electronic device as a server as an example, refer to Figure 2, which is a structural diagram of an electronic device 600 provided by an embodiment of the present application. The electronic device 600 shown in Figure 2 includes: at least one processor 610, a memory 640, and at least one network interface 620. The various components in the electronic device 600 are coupled together through a bus system 630. It can be understood that the bus system 630 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 630 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, various buses are labeled as bus system 630 in Figure 2.

[0065] The processor 610 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0066] The memory 640 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard drives, optical drives, etc. The memory 640 may optionally include one or more storage devices physically located away from the processor 610.

[0067] The memory 640 includes volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 640 described in the embodiments of the present application is intended to include any suitable type of memory.

[0068] In some embodiments, the memory 640 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplified below.

[0069] Operating system 641, including system programs for processing various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, and driver layer, which are used to implement various basic services and process hardware-based tasks;

[0070] A network communication module 642 for reaching other computing devices via one or more (wired or wireless) network interfaces 620 , exemplary network interfaces 620 including Bluetooth, WiFi, and USB;

[0071] In some embodiments, the device provided by the embodiments of the present application can be implemented in software. FIG2 shows a data table processing device 643 of a distributed database stored in a memory 640, which can be software in the form of programs and plug-ins, including the following software modules: an acquisition module 6431, an operation module 6432, a connection module 6433, and a determination module 6434. These modules are logical and can therefore be arbitrarily combined or further split according to the functions implemented. It should be pointed out that in FIG2, for the sake of convenience of expression, all the above modules are shown at once, but it should not be regarded as excluding the implementation of the data table processing device 643 of the distributed database that can only include the acquisition module 6431, the operation module 6432, and the connection module 6433. The functions of each module will be explained below.

[0072] The data table processing method of the distributed database provided in the embodiment of the present application will be specifically described below in combination with the exemplary application and implementation of the server provided in the embodiment of the present application.

[0073] For example, see Figure 3, which is a flow chart of a data table processing method of a distributed database provided in an embodiment of the present application, and will be explained in conjunction with the steps shown in Figure 3.

[0074] In step 101, a first data table and a second data table to be connected in a distributed database are obtained.

[0075] Here, the first data in the first data table and the second data in the second data table may be stored in a dispersed manner in multiple nodes of the distributed database.

[0076] For example, taking the first data in the first data table as an example, when the first data is the sales data of supermarket A, the sales data of different commodities in supermarket A can be distributed and stored in multiple nodes of the distributed database. For example, assuming that the sales data of supermarket A includes sales data of fresh food, sales data of electrical appliances, and sales data of clothing, the sales data of fresh food in supermarket A can be stored in node 1 of the distributed database, the sales data of electrical appliances in supermarket A can be stored in node 2 of the distributed database, and the sales data of clothing in supermarket A can be stored in node 3 of the distributed database. In other words, the distributed storage of the first data may be caused by different data types. Of course, the distributed storage of the first data may also be caused by different physical locations of computer rooms. For example, taking the first data of group A as an example, assuming that group A includes multiple subsidiaries, and different subsidiaries are located in different physical locations, the data of different subsidiaries can be distributed and stored in different nodes of the distributed database. For example, the data of subsidiary 1 can be stored in node 1 of the distributed database, and the data of subsidiary 2 can be stored in node 2 of the distributed database. Alternatively, the first data may need to be divided according to a fixed data volume, resulting in the distributed storage of the first data. For example, when the data volume of the first data is greater than the data volume threshold, the first data can be divided according to a fixed data volume, and the multiple sub-data obtained by the division can be distributed and stored in different nodes of the distributed database. The embodiments of the present application do not make specific limitations on this.

[0077] In some embodiments, taking the first data table (e.g., data table A) as an example, after selecting one or more columns from the first data table as distribution keys, a hash operation can be performed on the data columns according to the distribution keys, and then the data of the columns can be stored in the nodes corresponding to the calculated hash values. For example, a CdbHash structure can be first created using CdbHash*makeCdbHash(int numsegs, int natts, Oid*hashfuncs), and then the following operations can be performed on each column (tuple) to calculate the hash value corresponding to the column and determine to which node (segment) the data of the column should be distributed: first, an initialization operation is performed to initialize the hash initial value, then the hashDatum() function is called to perform different preprocessing for different types, and then the processed column value is added to the hash calculation, and finally the hash value is mapped to a node.

[0078] It should be noted that, in addition to distributing the first data in the first data table across multiple nodes of the distributed database through hash distribution, the first data in the first data table can also be distributed across multiple nodes through random distribution. For example, the first data in the first data table can be randomly distributed across different nodes of the distributed database. In this case, the same data will be stored in different nodes, and this is not specifically limited in the embodiments of the present application.

[0079] In addition, it should be noted that the first data table and the second data table in the embodiment of the present application can be the connection result after connecting multiple (2 or more) data tables. For example, when it is necessary to connect data table A, data table B and data table C in sequence, data table A and data table B can be connected first to obtain the connection result (corresponding to the first data table), and then the connection result can be continued to be connected with data table C (corresponding to the second data table). The embodiment of the present application does not make specific limitations on this.

[0080] In step 102 , a first data distribution of first data in a first data table and a second data distribution of second data in a second data table are obtained.

[0081] In some embodiments, the first data distribution of the first data in the first data table may refer to whether the distribution key of the first data table is a join key, and whether the data corresponding to the join key in the first data table includes high-frequency data; similarly, the second data distribution of the second data in the second data table may refer to whether the distribution key of the second data table is a join key, and whether the data corresponding to the join key in the second data table includes high-frequency data.

[0082] For example, taking the first data table as data table A and the second data table as data table B, the data distribution of data table A and the data distribution of data table B can be obtained respectively, for example, whether the distribution key of data table A is a join key, and whether the data corresponding to the join key in data table A includes high-frequency data, and whether the distribution key of data table B is a join key, and whether the data corresponding to the join key in data table B includes high-frequency data.

[0083] It should be noted that when joining a first data table (e.g., data table A) and a second data table (e.g., data table B), a join key must be specified. The process then determines whether the user-specified join key is the same as the distribution key used when distributing the data. If they are, the distribution key is the join key; if they are not, the distribution key is not the join key. Furthermore, determining whether a data table contains high-frequency data can include determining whether the number of occurrences of the data corresponding to the join key in the data table is greater than a threshold (e.g., 5000). If so, the data table contains high-frequency data; if not, the data table does not contain high-frequency data.

[0084] For example, let's assume that Data Table A is the order table and Data Table B is the order details table. Assume that the order table uses the order number as the distribution key to distribute data across multiple nodes, while the order details table uses the product name as the distribution key to distribute data across multiple nodes. Furthermore, assuming that the order table and the order details table need to be joined based on the product name (i.e., the join key), it can be determined that the order table's distribution key is not the join key, while the order details table's distribution key is the join key. Furthermore, using the order table as an example, if the join key is the product name, the number of occurrences of the data corresponding to the join key in the order table (e.g., purchase records for different products) can be used to determine whether high-frequency data exists in the order table. For example, if the number of purchase records for product A in the order table exceeds a threshold (e.g., 5000 occurrences), and if there are 6000 purchase records for product A in order table A, it can be determined that the order table contains high-frequency data.

[0085] In step 103, based on the first data distribution and the second data distribution, partial copying, partial redistribution and partial unchanged operations are performed on the full amount of data consisting of the first data and the second data to obtain the corresponding first data after operation and the second data after operation.

[0086] In some embodiments, refer to Figure 4, which is a flow chart of the data table processing method of the distributed database provided in an embodiment of the present application. As shown in Figure 4, step 103 shown in Figure 3 can be implemented by steps 1031 and 1032 shown in Figure 4, which will be explained in conjunction with the steps shown in Figure 4.

[0087] In step 1031, based on the first data distribution and the second data distribution, determine the third data used to perform the copy operation in the full data composed of the first data and the second data, the fourth data used to perform the redistribution operation in the full data, and the fifth data that remains unchanged in the full data.

[0088] It should be noted that the third data, fourth data, and fifth data in the embodiment of the present application do not refer to a specific piece of data, but are a general term for a certain type of data. That is, the embodiment of the present application collectively refers to the multiple pieces of data used to perform the copy operation as the third data, collectively refers to the multiple pieces of data used to perform the redistribution operation as the fourth data, and collectively refers to the multiple pieces of data whose distribution method remains unchanged as the fifth data.

[0089] In some embodiments, step 1031 can be implemented in the following manner: in response to the fact that the distribution keys of the first data table and the second data table are not join keys, and the data corresponding to the join key in one of the data tables includes high-frequency data, wherein the high-frequency data is data that appears more than a threshold number of times (e.g., 5,000 times), the following processing is performed: data in the non-target data table that matches the high-frequency data (e.g., data that is the same as the high-frequency data) is used as the third data for performing the copy operation, wherein the non-target data table is a data table that does not include the high-frequency data in the first data table and the second data table; data in the target data table other than the high-frequency data and data in the non-target data table other than the data that matches the high-frequency data are used as the fourth data for performing the redistribution operation, wherein the target data table is a data table that includes the high-frequency data in the first data table and the second data table; and the high-frequency data is used as the fifth data that remains unchanged.

[0090] For example, taking the first data table as data table A and the second data table as data table B, assuming that the distribution keys of data table A and data table B are not join keys, and the data corresponding to the join keys in data table A include high-frequency data, then the data in data table B that matches the high-frequency data can be used as the third data for performing the copy operation. For example, assuming that the high-frequency data in data table A is (1, 3, 5), where "1" appears 5100 times in data table A, "3" appears 5500 times in data table A, and "5" appears 5400 times in data table A, then (1, 3, 5) in data table B can be used as the data that matches the high-frequency data in data table A, that is, the third data for performing the copy operation; the data other than the high-frequency data in data table A and the data other than the data that matches the high-frequency data in data table B can be used as the fourth data for performing the redistribution operation, that is, The data except (1, 3, 5) in A and the data except (1, 3, 5) in data table B are used as the fourth data for performing the redistribution operation; the data (1, 3, 5) in data table A is used as the fifth data with the distribution method unchanged. That is to say, when the distribution keys of the two data tables are not join keys, and the join key of one of the data tables includes high-frequency data, for the data table including high-frequency data, since the distribution key is not a join key, it can be considered that the high-frequency data is evenly distributed on multiple nodes, so there is no need to redistribute the high-frequency data. Instead, it is only necessary to copy the data in the other data table that matches the high-frequency data (for example, broadcast it to all nodes). In this way, since the high-frequency data is not redistributed, a large amount of data is avoided from being redistributed to the same node; at the same time, since the amount of high-frequency data is large, the high-frequency data is not redistributed, which also reduces data movement.

[0091] In other embodiments, the above-mentioned step 1031 can also be implemented in the following manner: in response to the fact that the distribution keys of the first data table and the second data table are not join keys, the data corresponding to the join key in the first data table include first high-frequency data, and the data corresponding to the join key in the second data table include second high-frequency data, wherein the first high-frequency data is data that appears in the first data table a number of times greater than a number threshold, and the second high-frequency data is data that appears in the second data table a number of times greater than a number threshold, and there is no overlap between the first high-frequency data and the second high-frequency data, the following processing is performed: the data in the first data table that matches the second high-frequency data and the data in the second data table that matches the first high-frequency data are used as third data for performing a copy operation; the data in the first data table other than the first high-frequency data and the data that matches the second high-frequency data and the data in the second data table other than the second high-frequency data and the data that matches the first high-frequency data are used as fourth data for performing a redistribution operation; the first high-frequency data and the second high-frequency data are used as fifth data that remain unchanged.

[0092] For example, taking the first data table as data table A and the second data table as data table B, assuming that the distribution keys of data table A and data table B are not join keys, the data corresponding to the join key in data table A includes the first high-frequency data, the data corresponding to the join key in data table B includes the second high-frequency data, and there is no overlap between the first high-frequency data and the second high-frequency data, then the data in data table A that matches the second high-frequency data and the data in data table B that matches the first high-frequency data can be used as the third data for performing the copy operation; the data in data table A other than the first high-frequency data and the data that matches the second high-frequency data, and the data in data table B other than the second high-frequency data and the data that matches the first high-frequency data can be used as the fourth data for performing the redistribution operation; the first high-frequency data and the second high-frequency data are used as the fifth data with the distribution method remaining unchanged. For example, assuming that the first high-frequency data in data table A is (1, 3, 5) and the second high-frequency data in data table B is (2, 4), then (2, 4) in data table A can be used as data matching the second high-frequency data, and (1, 3, 5) in data table B can be used as data matching the first high-frequency data; the data in data table A except (1, 2, 3, 4, 5) and the data in data table B except (1, 2, 3, 4, 5) are used as the fourth data for performing the redistribution operation; (1, 3, 5) in data table A and (2, 4) in data table B are used as the fifth data that remains unchanged. That is to say, when the distribution keys of the two data tables are not join keys, the join keys of the two data tables both include high-frequency data, and the high-frequency data do not overlap, for the high-frequency data, since the join key is not the distribution key and there is no overlap between the high-frequency data, the high-frequency data on this side can be considered to be evenly distributed on multiple nodes, so there is no need to redistribute it, and only the data on the opposite side that matches the high-frequency data needs to be copied to all nodes; and for the processing of non-high-frequency data, since the non-high-frequency data is evenly distributed, it can be redistributed to all nodes according to the join key, thereby ensuring even distribution.

[0093] In some embodiments, the above-mentioned step 1031 can also be implemented in the following manner: in response to the distribution key of one of the first data table and the second data table being a join key, the distribution key of the other data table being not a join key, and the data corresponding to the join key in the non-target data table includes high-frequency data, wherein the non-target data table is a data table in the first data table and the second data table whose distribution key is not a join key, and the high-frequency data is data in the non-target data table whose number of occurrences is greater than a threshold value, the following processing is performed: the data in the target data table that matches the high-frequency data is used as the third data for performing the copy operation, wherein the target data table is the data table in the first data table and the second data table whose distribution key is a join key; the data in the non-target data table other than the high-frequency data is used as the fourth data for performing the redistribution operation; the high-frequency data and the data in the target data table other than the data that matches the high-frequency data are used as the fifth data that remains unchanged.

[0094] For example, taking Table A as the first data table and Table B as the second data table, assuming that the distribution key of Table A is a join key and the distribution key of Table B is not a join key, and the data corresponding to the join key in Table B includes high-frequency data, then the data in Table A that matches the high-frequency data can be used as the third data for performing the copy operation; the data in Table B other than the high-frequency data can be used as the fourth data for performing the redistribution operation; and the high-frequency data and the data in Table A other than the data that matches the high-frequency data can be used as the fifth data with the distribution method remaining unchanged. For example, assuming that the high-frequency data is (1, 3, 5), then (1, 3, 5) in Table A can be used as the data that matches the high-frequency data; the data in Table B other than (1, 3, 5) can be used as the fourth data for performing the redistribution operation; and the data in Table B other than (1, 3, 5) can be used as the fifth data with the distribution method remaining unchanged. That is to say, when the distribution key of one data table is a join key, the distribution key of another data table is not a join key, and the data table on the side where the join key is not the distribution key includes high-frequency data, for the high-frequency data, for the data table on the side where the join key is the distribution key, it can be considered that the high-frequency data is evenly distributed among multiple nodes, and therefore can be kept locally, while the data that matches the high-frequency data in the data table on the side where the join key is not the distribution key needs to be copied to all nodes; for non-high-frequency data, since non-high-frequency data is evenly distributed, the non-high-frequency data in the data table on the side where the distribution key is the join key can be kept locally, and the non-high-frequency data in the data table on the other side can be redistributed according to the join key.

[0095] In other embodiments, the above-mentioned step 1031 can also be implemented in the following manner: in response to the fact that the distribution keys of the first data table and the second data table are not join keys, the data corresponding to the join key in the first data table includes first high-frequency data, the data corresponding to the join key in the second data table includes second high-frequency data, and there is overlap between the first high-frequency data and the second high-frequency data, the following processing is performed: the data in the first data table and the second data table that matches the high-frequency data of the non-overlapping part is used as the third data for performing the copy operation; the high-frequency data of the overlapping part and the remaining data in the first data table and the second data table are used as the fourth data for performing the redistribution operation, wherein the remaining data is the data in the first data table and the second data table except the first high-frequency data, the second high-frequency data, and the data matching the high-frequency data of the non-overlapping part; the high-frequency data of the non-overlapping part is used as the fifth data that remains unchanged.

[0096] For example, take the first data table as data table A and the second data table as data table B. Assume that the distribution keys of data table A and data table B are not join keys, the data corresponding to the join key in data table A includes the first high-frequency data, assuming it is (1, 3, 5), and the data corresponding to the join key in data table B includes the second high-frequency data, assuming it is (2, 3, 4), and there is overlap between the first high-frequency data and the second high-frequency data, that is, data (3). Then, the data that matches the high-frequency data of the non-overlapping part in data table A and data table B can be used as the third data for performing the copy operation, that is, (2, 4) in data table A and (2, 4) in data table B. (1, 5) is used as the third data for performing the copy operation; the high-frequency data in the overlapping part and the remaining data in data table A and data table B are used as the fourth data for performing the redistribution operation, that is, the high-frequency data (3) in the overlapping part, the data other than (1, 2, 3, 4, 5) in data table A, and the data other than (1, 2, 3, 4, 5) in data table B are used as the fourth data for performing the redistribution operation; the high-frequency data in the non-overlapping part is used as the fifth data that remains unchanged, that is, (1, 5) in data table A and (2, 4) in data table B are used as the fifth data with the distribution method remaining unchanged. In other words, for the case where the distribution keys of the two data tables are not the connection keys, the connection keys of the two data tables include high-frequency data, and the high-frequency data overlaps, for the high-frequency data, since the connection key is not the distribution key and there is overlap, there will be limitations in redistributing or copying the high-frequency data. Therefore, the high-frequency data in the overlapping part can be redistributed so that the high-frequency data goes to different nodes to ensure that the amount of data processed by each node is basically even.

[0097] It should be noted that the high-frequency data in the embodiments of the present application does not refer to a specific piece of data, but is a general term for a certain type of data. For example, data that appear in a data table more than a number threshold can be collectively referred to as high-frequency data. In other words, high-frequency data is a collection of data that appears more than a number threshold.

[0098] In other embodiments, the above-mentioned step 1031 can also be implemented in the following manner: in response to the distribution key of one of the first data table and the second data table being a join key, the distribution key of the other data table being not a join key, and the data corresponding to the join key in the target data table includes high-frequency data, wherein the target data table is a data table in the first data table and the second data table whose distribution key is a join key, and the high-frequency data is data in the target data table whose number of appearances is greater than a threshold value, the following processing is performed: the high-frequency data and the data in the non-target data table that matches the high-frequency data are used as the third data for performing the copy operation, wherein the non-target data table is a data table in the first data table and the second data table whose distribution key is not a join key; the data in the non-target data table other than the data matching the high-frequency data is used as the fourth data for performing the redistribution operation; and the data in the target data table other than the high-frequency data is used as the fifth data that remains unchanged.

[0099] For example, taking Table A as the first data table and Table B as the second data table, assuming that the distribution key of Table A is a join key and the distribution key of Table B is not a join key, and that the data corresponding to the join key in Table A includes high-frequency data, then the high-frequency data and the data in Table B that matches the high-frequency data can be used as the third data for performing the copy operation; the data in Table B other than the data that matches the high-frequency data can be used as the fourth data for performing the redistribution operation; and the data in Table A other than the high-frequency data can be used as the fifth data that remains unchanged. For example, taking the high-frequency data as (1, 3, 5), then (1, 3, 5) in Table A and (1, 3, 5) in Table B can be used as the third data for performing the copy operation; the data in Table B other than (1, 3, 5) can be used as the fourth data for performing the redistribution operation; and the data in Table A other than (1, 3, 5) can be used as the fifth data with the distribution method remaining unchanged. That is, if the distribution key of one data table is a join key and the distribution key of another data table is not a join key, and the data table whose distribution key is a join key includes high-frequency data, polling replication can be performed on the high-frequency data. For example, the first data item can be sent to the first node, the second data item can be sent to the second node, and so on, to ensure even distribution of data. For data that matches the high-frequency data in the data table on the side where the distribution key is not the join key, it can be replicated to all nodes. For non-high-frequency data, since non-high-frequency data is evenly distributed, the non-high-frequency data in the data table on the side where the distribution key is the join key can be kept locally, while the non-high-frequency data in the data table on the other side can be redistributed according to the join key.

[0100] In step 1032 , a copy operation is performed on the third data, a redistribution operation is performed on the fourth data, and the fifth data remains unchanged.

[0101] In some embodiments, for the above-mentioned first data table and second data table, the distribution keys are not join keys, and the data corresponding to the join key in one of the data tables includes high-frequency data; or, the distribution keys of the first data table and the second data table are not join keys, the data corresponding to the join key in the first data table includes first high-frequency data, the data corresponding to the join key in the second data table includes second high-frequency data, and there is no overlap between the first high-frequency data and the second high-frequency data; or, in the first data table and the second data table, the distribution key of one data table is a join key, the distribution key of the other data table is not a join key, and the data corresponding to the join key in the non-target data table (that is, the data table whose distribution key is not a join key) includes high-frequency data, the above-mentioned step 1032 can be implemented in the following manner: copy the third data to each node; redistribute the fourth data among multiple nodes according to the join key; and keep the distribution method of the fifth data among multiple nodes unchanged.

[0102] For example, for the third data identified from the full data, the third data can be sent to all nodes by broadcasting, so that a complete copy of the third data is stored in each node of the distributed database; for the fourth data identified from the full data, the fourth data can be redistributed to multiple nodes according to the connection key; of course, the data in one data table can be kept unchanged, and the data in another data table can be copied to all nodes; for the fifth data, the distribution method of the fifth data in multiple nodes can be kept unchanged.

[0103] In other embodiments, for the case where the distribution keys of the first data table and the second data table are not join keys, the data corresponding to the join key in the first data table include first high-frequency data, the data corresponding to the join key in the second data table include second high-frequency data, and there is overlap between the first high-frequency data and the second high-frequency data, the above-mentioned step 1032 can be implemented in the following manner: copy the third data to each node; redistribute the high-frequency data of the overlapping part in the fourth data to multiple nodes so that the high-frequency data of the overlapping part is evenly distributed in multiple nodes, and redistribute the remaining data in the fourth data among multiple nodes according to the join key; and keep the distribution method of the fifth data among multiple nodes unchanged.

[0104] For example, for the third data identified from the full data, the third data can be sent to all nodes of the distributed database by broadcasting, so that a complete copy of the third data is stored in each node.

[0105] For example, for the fourth data identified from the full amount of data, where the fourth data includes the high-frequency data of the overlapping part and the remaining data (that is, the data in the first data table and the second data table except the first high-frequency data, the second high-frequency data, and the data matching the high-frequency data of the non-overlapping part), for the high-frequency data of the overlapping part, the high-frequency data of the overlapping part can be redistributed to multiple nodes according to the set rules, so that the high-frequency data of the overlapping part is evenly distributed in the multiple nodes. For example, the high-frequency data of the overlapping part can be redistributed to multiple nodes by polling replication. For example For example, if the high-frequency data in the overlapping part includes 500 pieces of data and the number of nodes is 10, the first piece of data in the 500 pieces of data can be sent to the first node (that is, the first piece of data is stored in the first node), the second piece of data can be sent to the second node (that is, the second piece of data is stored in the second node), and so on, the tenth piece of data can be sent to the tenth node, and for the eleventh piece of data, the eleventh piece of data can be resent to the first node. In this way, the high-frequency data in the overlapping part can be evenly distributed among multiple nodes, avoiding the problem of data skew.

[0106] As for the remaining data included in the fourth data, the remaining data can be redistributed to multiple nodes according to the connection key. For example, the connection key can be used as a classification standard to classify the remaining data, and different types of data can be stored in different nodes, that is, one node only stores one type of data. For example, taking the connection key as the name of the product, the remaining data (such as the purchase records corresponding to multiple products) can be first classified according to the product name, and the purchase records of different types of products can be stored in different nodes. For example, the purchase records of fresh products can be stored in the first node, the purchase records of clothing products can be stored in the second node, and the purchase records of electronic products can be stored in the third node, that is, one node only stores the purchase records of one type of product.

[0107] For example, for the fifth data identified from the full amount of data, the distribution of the fifth data in the multiple nodes is kept unchanged.

[0108] In some embodiments, for the case where the distribution key of one of the first data table and the second data table is a join key, the distribution key of the other data table is not a join key, and the data corresponding to the join key in the target data table includes high-frequency data, the above-mentioned step 1032 can be implemented in the following manner: polling and copying the high-frequency data in the third data, and copying the data in the third data that matches the high-frequency data to each node; redistributing the fourth data among multiple nodes according to the join key; and keeping the distribution method of the fifth data among multiple nodes unchanged.

[0109] For example, the above-mentioned polling and replication of high-frequency data in the third data can be achieved in the following way: let n be an integer variable whose value increases from 1, the maximum value of n is N, N is the total number of data included in the high-frequency data, and iterate n to perform the following processing: determine the remainder obtained by dividing n by M, and copy the nth data to the node corresponding to the remainder in multiple nodes, where M is the total number of multiple nodes. When the remainder is 0, the data corresponding to the remainder is copied to the Mth node.

[0110] In other embodiments, the following processing can also be performed: in response to the data volume of one of the first data table and the second data table being greater than the data volume threshold, and the data volume of the other data table being less than the data volume threshold, the data in the data table whose data volume is less than the data volume threshold is copied to each node.

[0111] For example, taking the first data table as data table A and the second data table as data table B, assuming that the data volume of data table A is greater than the data volume threshold, and the data volume of data table B is less than the data volume threshold, that is, data table A is a large table and data table B is a small table, then the data in data table B can be copied to all nodes of the distributed database, that is, a complete copy of the data in data table B is stored in each node.

[0112] In step 104, a connection operation is performed on the operated first data and the operated second data to obtain a connection result.

[0113] It should be noted that data connection refers to the process of combining data from different data sources. The main purpose of connection is to merge and integrate information from different data sources for more in-depth analysis and decision-making. Among them, the main connection methods include: direct connection (that is, you can use programming languages ​​to directly access and operate data sources, and obtain and merge data by executing appropriate query statements or written code), database connection (when multiple databases are involved, you can use the connection tools or application programming interfaces (APIs) provided by the database management system to connect data from different databases), file connection (you can connect data from different files by reading and parsing files in the file system), and external system connection (you can connect to external systems and obtain the required information by calling the functions or data of these systems).

[0114] For example, the first data after the operation and the second data after the operation can be merged through different connection methods (for example, inner join, outer join, etc.). The connection operation can be based on one or more common fields or keys to establish a logical association between different data sources. The result of data connection can be a new data set with different columns or rows, reflecting the relationship and interaction between the original data. Data connection is a commonly used operation in data processing and analysis, which can help users discover connections and patterns between data, thereby supporting more in-depth data analysis and decision-making.

[0115] In some embodiments, after partially copying, partially redistributing, and partially keeping the full data unchanged based on the first data distribution and the second data distribution, a join operation can be performed on the first data in the first data table after the operation and the second data in the second data table after the operation to obtain a join result. When a subsequent join is required with another data table (e.g., a third data table), the join result can be joined with the third data table. The specific join process can be implemented with reference to the above, and the embodiments of this application will not be repeated here.

[0116] The data table processing method of a distributed database provided in an embodiment of the present application performs partial replication, partial redistribution, and partial unchanged operations on the full data for the first data table and the second data table to be connected in the distributed database based on the first data distribution of the first data table and the second data distribution of the second data table. In this way, the full data after the operation is basically evenly distributed among multiple nodes, avoiding the data skew problem caused by copying a large amount of data to the same node when redistributing the full data in the related technology, thereby improving data processing efficiency.

[0117] The following describes an exemplary application of the embodiments of the present application in a practical application scenario.

[0118] Data skew is a challenge for distributed databases. Under certain data distribution conditions, data skew can cause certain nodes in a distributed database to process hundreds or even thousands of times more data than other nodes, slowing down overall processing. For example, the results of testing data skew against a common database test set (such as TPCDS) are shown in Figure 5. The left figure shows the distribution of data skew for queries in TPCDS, and the right figure shows the relationship between data skew and execution time. Figure 5 shows that a significant portion of queries with long execution times are related to data skew. Therefore, properly addressing data skew can effectively improve query efficiency.

[0119] In view of this, an embodiment of the present application provides a data table processing method for a distributed database. For two data tables that need to be connected, while keeping most of the data distribution methods unchanged, the data in the two data tables are redistributed according to different data distributions by partially copying, partially redistributing, and partially keeping it unchanged (keep local), thereby solving the problem of data skew.

[0120] The following is a detailed description of the distributed database data table processing method provided in the embodiment of the present application.

[0121] In some embodiments, since data skew is very complex, the embodiments of the present application will handle data skew through the following categories.

[0122] 1) The distribution keys of the two tables to be joined (or the join result) are not join keys, and the join key of one of the tables (or the join result) includes a Most Common Value (MCV).

[0123] 2) The distribution keys of the two data tables to be joined (or the join result) are not join keys, and the join keys of the two data tables (or the join result) both contain high-frequency values ​​(that is, values ​​in a column that appear more than the threshold number of times, corresponding to the high-frequency data mentioned above), and the high-frequency values ​​do not overlap;

[0124] 3) The distribution keys of the two data tables to be joined (or the join result) are not join keys, and the join keys of the two data tables (or the join result) contain high-frequency values, and the high-frequency values ​​overlap;

[0125] 4) The distribution key of one data table (or the join result) is the join key, while the distribution key of the other data table (or the join result) is not the join key, and the data table (or the join result) on the side with the distribution key contains high-frequency values.

[0126] 5) The distribution key of one data table (or the join result) is the join key, the distribution key of the other data table (or the join result) is not the join key, and the data table (or the join result) on the side whose distribution key is not the join key contains high-frequency values.

[0127] The following is a detailed description of the above five situations.

[0128] In some embodiments, referring to FIG6 , FIG6 is a schematic diagram of the principle of a data table processing method of a distributed database provided by related technology. As shown in FIG6 , for the case where the distribution keys of the data tables (or connection results) on both sides of the connection are not connection keys, and the connection keys of the data tables (or connection results) on one side contain high-frequency values, when distributed according to the hash function, the high-frequency values ​​will be distributed to the same node.

[0129] For example, see Figure 7, which is a schematic diagram of the principle of the data table processing method of the distributed database provided by the embodiment of the present application. As shown in Figure 7, assuming that the left table includes high-frequency values, for the above situation, the improved solution provided by the embodiment of the present application includes the following parts: For the processing of high-frequency values: For the data table including the high-frequency value side, since the distribution key is not the connection key, it can be basically assumed that the high-frequency value is evenly distributed on multiple nodes. Therefore, the high-frequency value can be redistributed without broadcasting the data matching the high-frequency value in the database on the other side to all nodes. For example, assuming that the data table on the left keeps the high-frequency value (1, 3, 5) locally, it is necessary to copy (1, 3, 5) in the data table on the right to all nodes. This has the following advantages: First, there is no redistribution of the high-frequency value, avoiding the redistribution of a large amount of high-frequency data to the same node, resulting in data skew; second, since the amount of high-frequency value data is large, no redistribution is performed, which can reduce data movement. In addition, for the processing of non-high-frequency values, since non-high-frequency values ​​are evenly distributed, they can be redistributed according to the connection key, or one side remains unchanged and the other side copies the data to all nodes to ensure even distribution.

[0130] It's important to note that identical values ​​on either side must correspond to all matching values ​​on the other side. Round-robin distribution on one side ensures even data distribution. Data replication on the other side ensures identical values ​​are matched exactly once, guaranteeing data accuracy. Furthermore, to ensure all connected data has a chance to connect, high-frequency values ​​are maintained locally on one side while full-node replication is performed on the other side. This ensures that all identical values ​​in the join columns have a chance to connect. For other values, all values ​​are redistributed to the same nodes, ensuring that identical values ​​in the join columns also have a chance to connect. Therefore, despite the simultaneous occurrence of replicated, locally maintained, and distributed values ​​in the join columns, identical values ​​in the join columns are guaranteed to have a chance to connect, thus ensuring the correctness of the result set.

[0131] In other embodiments, refer to Figure 8, which is a schematic diagram of the principle of the data table processing method of the distributed database provided by the embodiment of the present application. As shown in Figure 8, for the case where the distribution keys of the data tables (or connection results) on both sides of the connection are not connection keys, the connection keys of the data tables (or connection results) on both sides contain high-frequency values, and the high-frequency values ​​do not overlap, the improvement scheme provided by the embodiment of the present application includes the following parts: For the processing of high-frequency values: for the high-frequency values ​​on both sides, since the connection key is not the distribution key and there is no overlap between the high-frequency values, the high-frequency values ​​on this side can also be kept locally, and the data matching the high-frequency values ​​on the opposite side needs to be copied to all nodes. For example, assuming that the high-frequency values ​​included in the data table on the left are (1, 3, 5) and the high-frequency values ​​included in the data table on the right are (2, 4), then for the data table on the left, the high-frequency values ​​(1, 3, 5) can be kept locally, and at the same time, (1, 3, 5) in the data table on the right can be copied to all nodes; similarly, for the data table on the right, after keeping the high-frequency values ​​(2, 4) locally, (2, 4) in the data table on the left needs to be copied to all nodes. For the processing of non-high frequency values, since non-high frequency values ​​are evenly distributed, they can be redistributed to all nodes according to the connection key to ensure even distribution.

[0132] In some embodiments, referring to FIG9 , FIG9 is a schematic diagram of the principle of a data table processing method of a distributed database provided by related technology. As shown in FIG9 , the distribution keys of the data tables (or connection results) on both sides of the connection are not connection keys, and the connection keys of the data tables (or connection results) on both sides contain high-frequency values, and the high-frequency values ​​overlap. When the high-frequency values ​​are redistributed, the data of a certain node will expand, resulting in a typical problem of data skew; when the high-frequency values ​​are copied, the amount of copied data will be too large; in addition, the amount of data processed by each node will also be amplified.

[0133] For example, see Figure 10, which is a schematic diagram of the principle of the data table processing method of the distributed database provided by the embodiment of the present application. As shown in Figure 10, in response to the above situation, the improvement scheme provided by the embodiment of the present application includes the following parts: For the processing of high-frequency values: For high-frequency values ​​on both sides, since the connection key is not the distribution key and there is overlap, redistribution or data replication will have limitations. Therefore, the data of the overlapping part of the high-frequency values ​​is rearranged, for example, the high-frequency values ​​of the overlapping part are redistributed to different nodes according to the rules, so that the high-frequency values ​​go to different nodes for processing. In this way, when formulating the execution plan, after the high-frequency values ​​are rearranged, the data distribution is basically balanced to ensure that the amount of data processed by each node is basically even. In other words, the benefit of rearrangement is that after the data distribution is rearranged, the amount of data processed by each node is as balanced as possible, reducing the impact of data skew.

[0134] In other embodiments, see Figure 11, which is a schematic diagram of the principle of the data table processing method of the distributed database provided by the embodiment of the present application. As shown in Figure 11, for the situation where the distribution key of the data table (or connection result) on one side is the connection key, and the data table (or connection result) on the side where the connection key is not the distribution key contains high-frequency values, the improvement scheme provided by the embodiment of the present application mainly includes the following parts: For the processing of high-frequency values: the high-frequency values ​​of the data table (or connection result) on the side where the connection key is the distribution key are kept locally, and the data matching the high-frequency values ​​in the data table (or connection result) on the side where the connection key is not the distribution key need to be copied to all nodes. For the processing of non-high-frequency values, since non-high-frequency values ​​are evenly distributed, the non-high-frequency values ​​in the data table on the side where the distribution key is the connection key can be kept locally, and the non-high-frequency values ​​in the data table on the other side can be redistributed according to the connection key.

[0135] In some embodiments, referring to FIG12 , FIG12 is a schematic diagram of the principle of the data table processing method of the distributed database provided by the embodiment of the present application. As shown in FIG12 , for the case where the distribution key of the data table (or connection result) on one side is the connection key, and the connection key includes a high-frequency value in the data table (or connection result) on the side where the distribution key is the connection key, the improvement scheme provided by the embodiment of the present application mainly includes the following parts: For the processing of high-frequency values: for the high-frequency values ​​in the data table (or connection result) on the side where the distribution key is the connection key, polling and replication are performed, that is, the first data is sent to the first node, the second data is sent to the second node, and so on, so as to ensure the average distribution of data; for the data that matches the high-frequency value in the data table (or connection result) on the side where the distribution key is not the connection key, it needs to be copied to all nodes. For the processing of non-high-frequency values, due to the uniform distribution, the non-high-frequency values ​​in the data table (or connection result) on the side where the distribution key is the connection key can be kept locally, and the non-high-frequency values ​​on the other side can be redistributed according to the connection key.

[0136] In other embodiments, refer to Figure 13, which is a schematic diagram of the principle of the data table processing method of the distributed database provided in an embodiment of the present application. As shown in Figure 13, if the data table on one side is particularly large and the data table on the other side is particularly small, and the cost of copying the data in the small table to all nodes is not high, the data on one side of the small table can be directly copied to all nodes.

[0137] The following will illustrate the beneficial effects of the data table processing method of the distributed database provided in the embodiment of the present application in combination with experimental data.

[0138] For example, see Figure 14, which is a schematic diagram comparing the effects provided by an embodiment of the present application. As shown in Figure 14, the embodiment of the present application was tested for a typical scenario of TPCDS. For the case of data skew, the technical solution provided by the embodiment of the present application (i.e., a solution of partial replication, partial redistribution, and partial retention) is improved to a certain extent compared with the technical solution provided by the related art (i.e., a solution of redistribution or replication). For example, for SQL 78, the execution time is shortened from 3666 milliseconds to 2482 milliseconds; for SQL 16, the execution time is shortened from 2416 milliseconds to 2182 milliseconds.

[0139] The following continues to describe an exemplary structure of the data table processing device 643 of the distributed database provided in an embodiment of the present application implemented as a software module. In some embodiments, as shown in Figure 2, the software modules in the data table processing device 643 of the distributed database stored in the memory 640 may include: an acquisition module 6431, an operation module 6432 and a connection module 6433.

[0140] The acquisition module 6431 is configured to acquire the first data table and the second data table to be connected in a distributed database, wherein the first data in the first data table and the second data in the second data table are stored in a plurality of nodes in a dispersed manner; the acquisition module 6431 is further configured to acquire the first data distribution of the first data and the second data distribution of the second data; the operation module 6432 is configured to perform partial replication, partial redistribution, and partial unchanged operations on the full amount of data consisting of the first data and the second data based on the first data distribution and the second data distribution, to obtain the corresponding first data after the operation and the second data after the operation; the connection module 6433 is configured to perform a connection operation on the first data after the operation and the second data after the operation to obtain a connection result.

[0141] In some embodiments, the data table processing device 643 of the distributed database also includes a determination module 6434, which is configured to determine, based on the first data distribution and the second data distribution, third data for performing a copy operation in the full amount of data composed of the first data and the second data, fourth data for performing a redistribution operation in the full amount of data, and fifth data that remains unchanged in the full amount of data; the operation module 6432 is also configured to perform a copy operation on the third data, perform a redistribution operation on the fourth data, and keep the fifth data unchanged.

[0142] In some embodiments, the determination module 6434 is further configured to perform the following processing in response to the fact that the distribution keys of the first data table and the second data table are not join keys, and the data corresponding to the join key in one of the data tables includes high-frequency data, wherein the high-frequency data is data that appears more than a threshold number of times: using the data in the non-target data table that matches the high-frequency data as the third data for performing the copy operation, wherein the non-target data table is a data table that does not include high-frequency data in the first data table and the second data table; using the data in the target data table other than the high-frequency data, and the data in the non-target data table other than the data that matches the high-frequency data as the fourth data for performing the redistribution operation, wherein the target data table is a data table that includes high-frequency data in the first data table and the second data table; and using the high-frequency data as the fifth data that remains unchanged.

[0143] In some embodiments, the determination module 6434 is further configured to perform the following processing in response to the fact that the distribution keys of the first data table and the second data table are not join keys, the data corresponding to the join key in the first data table includes first high-frequency data, and the data corresponding to the join key in the second data table includes second high-frequency data, wherein the first high-frequency data is data that appears in the first data table more than a number threshold, the second high-frequency data is data that appears in the second data table more than a number threshold, and there is no overlap between the first high-frequency data and the second high-frequency data: use the data in the first data table that matches the second high-frequency data and the data in the second data table that matches the first high-frequency data as the third data for performing the copy operation; use the data in the first data table other than the first high-frequency data and the data that matches the second high-frequency data, and the data in the second data table other than the second high-frequency data and the data that matches the first high-frequency data as the fourth data for performing the redistribution operation; use the first high-frequency data and the second high-frequency data as the fifth data that remains unchanged.

[0144] In some embodiments, the determination module 6434 is further configured to perform the following processing in response to the distribution key of one of the first data table and the second data table being a join key, the distribution key of the other data table being not a join key, and the data corresponding to the join key in the non-target data table including high-frequency data, wherein the non-target data table is a data table in the first data table and the second data table whose distribution key is not a join key, and the high-frequency data is data in the non-target data table whose number of occurrences is greater than a threshold value: using the data in the target data table that matches the high-frequency data as the third data for performing the copy operation, wherein the target data table is the data table in the first data table and the second data table whose distribution key is a join key; using the data in the non-target data table other than the high-frequency data as the fourth data for performing the redistribution operation; and using the high-frequency data and the data in the target data table other than the data that matches the high-frequency data as the fifth data that remains unchanged.

[0145] In some embodiments, the operation module 6432 is further configured to copy the third data to each node; redistribute the fourth data among multiple nodes according to the connection key; and keep the distribution of the fifth data among multiple nodes unchanged.

[0146] In some embodiments, the determination module 6434 is further configured to perform the following processing in response to the fact that neither the distribution key of the first data table nor the second data table is a join key, the data corresponding to the join key in the first data table includes first high-frequency data, the data corresponding to the join key in the second data table includes second high-frequency data, and there is overlap between the first high-frequency data and the second high-frequency data: use the data in the first data table and the second data table that matches the high-frequency data in the non-overlapping part as the third data for performing the copy operation; use the high-frequency data in the overlapping part and the remaining data in the first data table and the second data table as the fourth data for performing the redistribution operation, wherein the remaining data is the data in the first data table and the second data table other than the first high-frequency data, the second high-frequency data, and the data that matches the high-frequency data in the non-overlapping part; use the high-frequency data in the non-overlapping part as the fifth data that remains unchanged.

[0147] In some embodiments, the operation module 6432 is further configured to copy the third data to each node; redistribute the high-frequency data of the overlapping part of the fourth data to multiple nodes so that the high-frequency data of the overlapping part is evenly distributed in multiple nodes, and redistribute the remaining data in the fourth data among multiple nodes according to the connection key; and keep the distribution of the fifth data in multiple nodes unchanged.

[0148] In some embodiments, the determination module 6434 is further configured to perform the following processing in response to the distribution key of one of the first data table and the second data table being a join key, the distribution key of the other data table being not a join key, and the data corresponding to the join key in the target data table including high-frequency data, wherein the target data table is a data table in the first data table and the second data table whose distribution key is a join key, and the high-frequency data is data in the target data table whose number of appearances is greater than a threshold number, as the third data for performing the copy operation, wherein the non-target data table is a data table in the first data table and the second data table whose distribution key is not a join key; the data in the non-target data table other than the data matching the high-frequency data is used as the fourth data for performing the redistribution operation; and the data in the target data table other than the high-frequency data is used as the fifth data that remains unchanged.

[0149] In some embodiments, the operation module 6432 is further configured to perform polling replication on the high-frequency data in the third data, and to copy the data in the third data that matches the high-frequency data to each node; to redistribute the fourth data among multiple nodes according to the connection key; and to keep the distribution of the fifth data among multiple nodes unchanged.

[0150] In some embodiments, the operation module 6432 is further configured to let n be an integer variable whose value increases starting from 1, the maximum value of n is N, N is the total number of data included in the high-frequency data, and iterate n to perform the following processing: determine the remainder obtained by dividing n by M, and copy the nth data to the node corresponding to the remainder in multiple nodes, where M is the total number of multiple nodes, and when the remainder is 0, copy the data corresponding to the remainder to the Mth node.

[0151] In some embodiments, the operation module 6432 is further configured to copy the data in the data table whose data volume is less than the data volume threshold to each node in response to the data volume of one of the first data table and the second data table being greater than the data volume threshold and the data volume of the other data table being less than the data volume threshold.

[0152] It should be noted that the description of the device of the embodiment of the present application is similar to the description of the method embodiment described above, and has similar beneficial effects as the method embodiment, so it will not be repeated here. For the technical details not covered in the data table processing device of the distributed database provided in the embodiment of the present application, they can be understood based on the description of either Figure 3 or Figure 4.

[0153] An embodiment of the present application provides a computer program product, comprising a computer program or computer-executable instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, causing the computer device to perform the data table processing method for a distributed database described in the embodiment of the present application.

[0154] An embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, the processor will execute the data table processing method of the distributed database provided by the embodiment of the present application, for example, the data table processing method of the distributed database shown in Figure 3 or Figure 4.

[0155] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or various devices including one or any combination of the above memories.

[0156] In some embodiments, executable instructions may be in the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.

[0157] As an example, executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed across multiple sites and interconnected by a communication network.

[0158] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, and improvements made within the spirit and scope of the present application are included in the scope of protection of the present application.

Claims

1. A data table processing method of a distributed database, executed by an electronic device, wherein the distributed database includes a plurality of nodes; the method includes: Acquire a first data table and a second data table to be connected in the distributed database, wherein first data in the first data table and second data in the second data table are dispersedly stored in the plurality of nodes; Acquire a first data distribution of the first data in the first data table, and a second data distribution of the second data in the second data table; Based on the first data distribution and the second data distribution, performing operations of partially copying, partially redistributing, and partially keeping unchanged on the full amount of data consisting of the first data and the second data, to obtain corresponding first data after the operation and second data after the operation; A connection operation is performed on the operated first data and the operated second data to obtain a connection result.

2. The method according to claim 1, wherein: The performing of partial replication, partial redistribution, and partial unchanged operations on the full amount of data consisting of the first data and the second data based on the first data distribution and the second data distribution includes: Based on the first data distribution and the second data distribution, determine third data for performing a copy operation in the full data consisting of the first data and the second data, fourth data for performing a redistribution operation in the full data, and fifth data that remains unchanged in the full data; The copy operation is performed on the third data, the redistribution operation is performed on the fourth data, and the fifth data is kept unchanged.

3. The method according to claim 2, wherein: The determining, based on the first data distribution and the second data distribution, third data for performing a copy operation in the full data consisting of the first data and the second data, fourth data for performing a redistribution operation in the full data, and fifth data remaining unchanged in the full data includes: In response to the fact that neither the distribution key of the first data table nor the second data table is a join key, and the data corresponding to the join key in one of the data tables includes high-frequency data, wherein the high-frequency data is data that appears more than a threshold number of times, the following processing is performed: using data in a non-target data table that matches the high-frequency data as third data for performing a copy operation, wherein the non-target data table is a data table that does not include the high-frequency data in the first data table and the second data table; using data other than the high-frequency data in a target data table and data other than the data matching the high-frequency data in a non-target data table as fourth data for performing a redistribution operation, wherein the target data table is a data table including the high-frequency data in the first data table and the second data table; The high frequency data is regarded as the fifth data which remains unchanged.

4. The method according to claim 2, wherein: The determining, based on the first data distribution and the second data distribution, third data for performing a copy operation in the full data consisting of the first data and the second data, fourth data for performing a redistribution operation in the full data, and fifth data remaining unchanged in the full data includes: In response to the fact that neither the distribution key of the first data table nor the distribution key of the second data table is a join key, the data corresponding to the join key in the first data table includes first high-frequency data, and the data corresponding to the join key in the second data table includes second high-frequency data, wherein the first high-frequency data is data in the first data table that appears more than a number threshold, the second high-frequency data is data in the second data table that appears more than a number threshold, and there is no overlap between the first high-frequency data and the second high-frequency data, the following processing is performed: using the data in the first data table that matches the second high-frequency data and the data in the second data table that matches the first high-frequency data as third data for performing a copy operation; using data in the first data table other than the first high-frequency data and data matching the second high-frequency data, and data in the second data table other than the second high-frequency data and data matching the first high-frequency data as fourth data for performing a redistribution operation; The first high-frequency data and the second high-frequency data are used as fifth data that remain unchanged.

5. The method according to claim 2, wherein: The determining, based on the first data distribution and the second data distribution, third data for performing a copy operation in the full data consisting of the first data and the second data, fourth data for performing a redistribution operation in the full data, and fifth data remaining unchanged in the full data includes: In response to the distribution key of one of the first data table and the second data table being a join key, the distribution key of the other data table being not a join key, and the data corresponding to the join key in the non-target data table including high-frequency data, wherein the non-target data table is a data table in the first data table and the second data table whose distribution key is not a join key, and the high-frequency data is data in the non-target data table whose occurrence number is greater than a number threshold, the following processing is performed: Using data in a target data table that matches the high-frequency data as third data for performing a copy operation, wherein the target data table is a data table in which the distribution key in the first data table and the second data table is a connection key; using the data in the non-target data table other than the high-frequency data as fourth data for performing a redistribution operation; The high-frequency data and data in the target data table other than data matching the high-frequency data are regarded as fifth data that remain unchanged.

6. The method according to any one of claims 2 to 5, wherein: The performing the copy operation on the third data, performing the redistribution operation on the fourth data, and keeping the fifth data unchanged, comprises: Copying the third data to each of the nodes; redistributing the fourth data among the multiple nodes according to the connection key; The distribution manner of the fifth data in the plurality of nodes is kept unchanged.

7. The method according to claim 2, wherein: The determining, based on the first data distribution and the second data distribution, third data for performing a copy operation in the full data consisting of the first data and the second data, fourth data for performing a redistribution operation in the full data, and fifth data remaining unchanged in the full data includes: In response to the fact that neither the distribution key of the first data table nor the distribution key of the second data table is a join key, the data corresponding to the join key in the first data table includes first high-frequency data, the data corresponding to the join key in the second data table includes second high-frequency data, and there is overlap between the first high-frequency data and the second high-frequency data, the following processing is performed: using data in the first data table and the second data table that matches the high-frequency data of the non-overlapping portion as third data for performing a copy operation; Using the high-frequency data of the overlapping portion and the remaining data in the first data table and the second data table as fourth data for performing a redistribution operation, wherein the remaining data is data in the first data table and the second data table other than the first high-frequency data, the second high-frequency data, and the data matching the high-frequency data of the non-overlapping portion; The high frequency data of the non-overlapping portion is regarded as the fifth data which remains unchanged.

8. The method according to claim 7, wherein: The performing the copy operation on the third data, performing the redistribution operation on the fourth data, and keeping the fifth data unchanged, comprises: Copying the third data to each of the nodes; redistributing the high-frequency data of the overlapping portion in the fourth data to the plurality of nodes so that the high-frequency data of the overlapping portion is evenly distributed in the plurality of nodes, and redistributing the remaining data in the fourth data among the multiple nodes according to the connection keys; The distribution manner of the fifth data in the plurality of nodes is kept unchanged.

9. The method according to claim 2, wherein: The determining, based on the first data distribution and the second data distribution, third data for performing a copy operation in the full data consisting of the first data and the second data, fourth data for performing a redistribution operation in the full data, and fifth data remaining unchanged in the full data includes: In response to the distribution key of one of the first data table and the second data table being a join key, the distribution key of the other data table being not a join key, and the data corresponding to the join key in the target data table includes high-frequency data, wherein the target data table is a data table in which the distribution key of the first data table and the second data table is a join key, and the high-frequency data is data in the target data table whose number of occurrences is greater than a number threshold, the following processing is performed: Using the high-frequency data and data in a non-target data table that matches the high-frequency data as third data for performing a copy operation, wherein the non-target data table is a data table in the first data table and the second data table whose distribution key is not a join key; using the data in the non-target data table other than the data matching the high-frequency data as fourth data for performing a redistribution operation; The data in the target data table other than the high-frequency data is regarded as fifth data which remains unchanged.

10. The method according to claim 9, wherein: The performing the copy operation on the third data, performing the redistribution operation on the fourth data, and keeping the fifth data unchanged, comprises: Performing polling replication on the high-frequency data in the third data, and replicating the data in the third data that matches the high-frequency data to each of the nodes; redistributing the fourth data among the multiple nodes according to the connection key; The distribution manner of the fifth data in the plurality of nodes is kept unchanged.

11. The method according to claim 10, wherein: The polling and copying of the high-frequency data in the third data includes: Let n be an integer variable whose value increases from 1, the maximum value of n is N, N is the total number of data included in the high-frequency data, and iterate n to perform the following processing: Determine the remainder obtained by dividing n by M, and copy the nth data to the node corresponding to the remainder among the multiple nodes, where M is the total number of the multiple nodes, and when the remainder is 0, copy the data corresponding to the remainder to the Mth node.

12. The method according to any one of claims 1 to 11, wherein: The method further comprises: In response to the data volume of one of the first data table and the second data table being greater than a data volume threshold and the data volume of the other data table being less than the data volume threshold, the data in the data table having a data volume less than the data volume threshold is copied to each of the nodes.

13. A data table processing device for a distributed database, the distributed database comprising a plurality of nodes; the device comprising: An acquisition module is configured to acquire a first data table and a second data table to be connected in the distributed database, wherein the first data in the first data table and the second data in the second data table are dispersedly stored in the plurality of nodes; The acquisition module is further configured to acquire a first data distribution of the first data in the first data table, and a second data distribution of the second data in the second data table; an operation module configured to perform operations of partially copying, partially redistributing, and partially keeping unchanged on the full amount of data consisting of the first data and the second data based on the first data distribution and the second data distribution, so as to obtain corresponding first data after operation and second data after operation; The connection module is configured to perform a connection operation on the operated first data and the operated second data to obtain a connection result.

14. An electronic device comprising: A memory for storing executable instructions; The processor is used to implement the data table processing method of the distributed database as described in any one of claims 1 to 12 when executing the executable instructions stored in the memory.

15. A computer-readable storage medium storing computer-executable instructions, wherein when the computer-executable instructions are executed by a processor, the distributed database data table processing method according to any one of claims 1 to 12 is implemented.

16. A computer program product, comprising a computer program or a computer executable instruction, wherein when the computer program or the computer executable instruction is executed by a processor, the distributed database data table processing method according to any one of claims 1 to 12 is implemented.

Citation Information

Patent Citations

  • Performance optimization method and device for distributed database

    CN112115123A

  • Data redistribution method and electronic equipment

    CN115934311A

  • Data table processing method and device of distributed database, equipment and storage medium

    CN116627965A

  • Techniques for resource description framework modeling within distributed database systems

    US20160371355A1

  • Data redistribution method, device, and system

    WO2021046750A1