A distributed Hash Join hotspot bucket optimization execution method
By real-time detection and splitting of hot buckets in a distributed database system, and by optimizing local Hash Joins using local parallel execution units, the performance problem caused by abnormally concentrated load on hash buckets is solved, thereby improving query execution efficiency and resource utilization.
Patent Information
- Application Number
- CN202611713189.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-11-02
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies cannot effectively solve the problems of long tails in query execution, memory consumption, and overflow pressure caused by abnormally concentrated load on a single hash bucket during the execution of local Hash Join in distributed database systems. In particular, they cannot detect and optimize dynamically formed hot buckets in real time.
During the execution of a local Hash Join, multi-dimensional load information at the bucket level is collected in real time. Hot buckets are identified by comprehensive load scores, and secondary splitting and parallel processing are performed to generate local remapping descriptors. The number of sub-buckets is dynamically adjusted, and hot buckets are optimized using local parallel execution units to avoid cross-node data transmission and global reconstruction.
It achieves real-time optimization of dynamic hotspot buckets, shortens query execution time, reduces memory and spill pressure, improves performance, and controls additional overhead, making it suitable for existing distributed database executor frameworks.
Smart Images

Figure CN123178451A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of distributed database query optimization technology, specifically to a distributed Hash Join hotspot bucket optimization method. Background Technology
[0002] In large-scale distributed database systems, equi-join queries are typically implemented using the Hash Join algorithm. The system first redistributes the data from the two tables involved in the join across multiple data nodes based on the join key. Then, each data node performs a local Hash Join in its local executor. Hash Join, with its high throughput and strong versatility, is widely used in online analytical processing (OLAP), multi-table join analysis, and mixed transaction analysis scenarios.
[0003] In existing technologies, when data nodes perform a partial hash join, they typically first calculate the hash value of the data on the construction side and write it into multiple buckets of a hash table. Then, the data on the probe side accesses the corresponding bucket according to the same hash rule to complete the join matching. For scenarios with insufficient memory, existing solutions often use mechanisms such as batch expansion, spill writing to disk, and ordinary parallel execution to alleviate resource pressure.
[0004] Currently, existing solutions for optimizing Hash Join skew can be mainly categorized as follows: Heavy hitter identification schemes: These schemes identify skewed keys through sampling or statistical information before the join operation and use broadcasting, replication, or special distribution strategies for heavy hitters to reduce the load on some nodes. However, these schemes rely on pre-identified heavy hitters and cannot handle the problem of hot buckets formed by the aggregation of non-heavy hitters due to hash collisions and concentrated access patterns during operation.
[0005] Distributed avoidance schemes based on redistribution: During the optimizer phase, redistribution operations, broadcast operations, and reselection of distribution keys are used to avoid skew affecting subsequent join execution at the data distribution level. However, such schemes have a large adjustment range and high execution costs, and belong to global optimization in the planning phase, so they cannot be used as fine-grained local optimization methods in the execution phase.
[0006] The actuator skew bucket solution: Based on the most common value (MCV) statistics, a dedicated skew bucket or skew hash table is created for known hot values to reduce spills and improve the efficiency of initial data processing. However, this solution still relies on pre-statistical hot values and cannot handle ordinary hot buckets that are dynamically formed at runtime.
[0007] A typical parallel hash join solution uses multiple execution units to process different buckets or batches, achieving parallel processing between buckets. However, this solution only achieves bucket-level parallelism. If the data volume or access volume of a single bucket far exceeds that of other buckets, the hot bucket will still become the long tail of execution and cannot be further split and parallelized.
[0008] Taking typical distributed databases such as Greenplum and TBase as examples, they already support optimization capabilities such as optimizer skew avoidance, executor skew buckets, data redistribution, and parallel hash joins. However, the above solutions are all geared towards hot value levels, data redistribution levels, or the static planning stage, and do not solve the fine-grained execution problem of "abnormally concentrated load on a single ordinary first-level hash bucket during runtime." Even if data skew exists, when the skew is concentrated within a single bucket, existing solutions cannot perform secondary splitting and parallel processing on that bucket during the execution phase, ultimately leading to significant long tails in query execution, concentrated memory usage, and increased overflow pressure.
[0009] Therefore, there is an urgent need for a runtime executor-level local optimization method that can detect bucket-level load in real time during the execution of local Hash Join, perform secondary splitting and intra-bucket parallelism only on the identified hot buckets, and shorten the execution long tail and reduce memory and spill pressure without changing the overall distributed Join framework. Summary of the Invention
[0010] The present invention proposes a distributed Hash Join hotspot bucket optimization execution method, which can at least solve one of the technical problems in the background art.
[0011] To achieve the above objectives, the present invention adopts the following technical solution: A distributed Hash Join hotspot bucket optimization method includes the following steps: S1. The coordinating node distributes the local Hash Join task in the distributed execution plan to multiple data nodes, and each data node executes the local Hash Join task in its local executor. S2. Within a single data node, select the data on the construction side and calculate the hash value of the connection key according to the first-level hash rule. Map the construction side records into multiple first-level buckets to form a local hash table. S3. During the hash table construction phase or the probe matching phase, continuously collect and update the bucket-level runtime statistics of each first-level bucket in real time. S4. Based on the preset hot spot determination conditions, check the runtime statistics of each first-level bucket to determine whether there is a target hot spot bucket that meets the hot spot conditions; if no hot spot bucket is identified, all first-level buckets are treated as ordinary buckets and the join process is performed along the original Hash Join path. S5. If a target hotspot bucket is identified, a local remapping descriptor is generated for the target hotspot bucket, and the configuration parameters required for splitting are recorded. S6. Based on the local remapping descriptor, perform the second-level hash mapping only on all records in the target hotspot bucket to complete the secondary split of the hotspot bucket; S7. After splitting, multiple sub-buckets are formed, and the processing tasks of each sub-bucket are added to the local task queue of the current data node. S8. Schedule multiple local parallel execution units within the current data node to each receive and execute the Hash Join processing task of the corresponding sub-bucket. S9. After all sub-buckets have been processed, summarize the sub-bucket connection results output by each parallel execution unit to obtain the overall connection result of the hot spot bucket. S10. The overall connection results of the hotspot bucket and the connection results of all ordinary buckets are summarized in a unified manner, and the local connection results of the current data node are output. Finally, the upper-level node summarizes the local connection results of all data nodes to generate the final query result.
[0012] As a preferred embodiment of the distributed Hash Join hot bucket optimization execution method of the present invention, wherein the bucket-level runtime statistics in step S3 include the number of records in the bucket, the cumulative number of bytes in the bucket, the maximum length of the conflict chain, the bucket memory usage, the number of probe accesses, the cumulative probe time, the amount of spilled bytes, and the number of spills; The system calculates a comprehensive load score for each first-level bucket. The calculation formula is:
[0013] in , , , , For configurable weighting coefficients, This means that the corresponding indicator will be normalized according to the average value of all first-level buckets in the current data node; This indicates the number of records in the current first-level bucket after the first-level hash calculation is performed on the construction end; This indicates the cumulative number of bytes in the current first-level bucket after the first-level hash calculation is performed on the construction end; This represents the length of the collision chain that contains the most tuples among the collision chains formed due to hash collisions. This represents the cumulative number of tuples that the probe has mapped and accessed after the first-level hash calculation. This metric counts the number of probes that have entered the bucket. This represents the cumulative number of bytes written to temporary storage due to insufficient available memory for hash join. When no disk overflow occurs, this metric is 0. The comprehensive load score serves as the core basis for hotspot determination in step S4.
[0014] As a preferred embodiment of the distributed Hash Join hotspot bucket optimization execution method of the present invention, wherein: the preset hotspot determination condition in step S4 adopts a joint determination combining a fixed threshold and a relative threshold, and the first-level bucket is determined to be the target hotspot bucket when any one of the following conditions is met: The number of records in the bucket exceeds a preset multiple of the average number of records in all first-level buckets of the current data node; The cumulative number of bytes in the bucket exceeds the preset single-bucket memory budget threshold; The maximum length of the hash collision chain within the bucket exceeds the preset chain length threshold. The cumulative number of detections or the cumulative detection time of the detection phase bucket exceeds the preset detection number threshold or the preset detection time threshold; The overall load score of the bucket exceeds the preset overall score threshold.
[0015] As a preferred embodiment of the distributed Hash Join hot bucket optimization execution method of the present invention, wherein the local remapping descriptor in step S5 includes at least four pieces of information: the original bucket number, the splitting level identifier, the second-level hash function identifier, and the number of sub-buckets; In step S6, the second-level hash mapping is still based on the join key calculation, but it uses a different bit selection rule or mapping space than the first-level hash. The sub-bucket number is calculated as follows:
[0016] in For the second-level hash function, The number of sub-buckets configured.
[0017] As a preferred embodiment of the distributed Hash Join hotspot bucket optimization execution method of the present invention, wherein: the number of sub-buckets Dynamically adjust based on the hotspot level of the hotspot bucket and the current node resource status: When the number of records in the hotspot bucket is a first multiple of the number of records in the average bucket, the number of sub-buckets is set to the first tier value; when the number of records in the hotspot bucket is a second multiple of the number of records in the average bucket, the number of sub-buckets is set to the second tier value, wherein the value in the second multiple is greater than the value in the first multiple, and the value in the second tier is greater than the value in the first tier. At the same time, the number of sub-buckets is matched with the number of idle parallel execution units of the current data node, ensuring that each sub-bucket can be assigned to an independent execution unit for processing.
[0018] As a preferred embodiment of the distributed Hash Join hotspot bucket optimization execution method described in this invention, steps S3 and S4 are executed in real time during the hash table construction phase: During the process of writing build-side data to the first-level bucket in batches, the runtime statistics of each bucket are updated synchronously. When the build-side load metric of any bucket exceeds the hotspot threshold, the secondary splitting process is immediately triggered. Records already written to the hotspot bucket are remapped and split, and the remaining unwritten build-side records are directly written to the corresponding sub-buckets according to the second-level hash rules, without needing to be written to the first-level bucket before splitting.
[0019] As a preferred embodiment of the distributed Hash Join hotspot bucket optimization execution method described in this invention, steps S3 and S4 are executed in real time during the probing and matching phase: When the load metrics of all first-level buckets do not reach the hotspot threshold during the construction phase, but during the probing phase, the probing side records concentrated access to some first-level buckets, resulting in the number of probing accesses and the cumulative probing time of the corresponding buckets being significantly higher than those of other buckets, the buckets of this type are identified as hotspot buckets based on the runtime statistics of the probing phase and a second split is triggered; after the split is completed, subsequent probing records are directly distributed to the corresponding sub-buckets for matching according to the second-level hash rules.
[0020] As a preferred embodiment of the distributed Hash Join hotspot bucket optimization execution method of the present invention, wherein: when performing a secondary split on the hotspot bucket in step S6, a hotspot key-aware splitting method is adopted: First, scan all build-side records in the hotspot bucket, count the frequency of each connection key value, and classify the connection key values whose frequency exceeds the key frequency threshold into hotspot key set, and the rest into non-hotspot key set; divide the records corresponding to the hotspot key set into at least one logical sub-bucket, and divide the records corresponding to the non-hotspot key set into multiple ordinary sub-buckets according to the second-level hash rule, and then hand them over to different parallel execution units for processing.
[0021] As a preferred embodiment of the distributed Hash Join hotspot bucket optimization execution method described in this invention, when the memory usage of the hotspot bucket exceeds a threshold and triggers a spill operation, an independent spill mechanism for the sub-buckets is adopted. After the second-level hash split is completed, each sub-bucket is independently spilled to an independent file segment on the disk, and each sub-bucket corresponds to a dedicated spill storage area; during readback processing, the sub-buckets are loaded into memory in segments, and the corresponding parallel execution units are independently responsible for the readback and join matching operations of the sub-bucket spill files.
[0022] The beneficial effects of this invention are: This invention does not rely on pre-statistical hot spot values, but instead collects multi-dimensional load information at the bucket level in real time during the execution of local Hash Join. It can identify dynamic hot spot buckets formed by various reasons such as hash collisions and concentrated access patterns, and cover tilt scenarios that cannot be perceived by static statistics.
[0023] This invention does not require a global reconstruction of the entire Hash Join, nor does it uniformly increase the parallelism of all buckets. It only performs secondary splitting on the identified abnormal hot buckets, while ordinary buckets maintain their original execution paths, thus improving performance while strictly controlling additional overhead.
[0024] This invention prioritizes scheduling parallel execution units within the current data node to process sub-buckets, eliminating the need for cross-node data redistribution. This avoids the overhead of cross-node transmission, consistency management, and global scheduling, and is easy to embed into existing distributed database executor frameworks. Attached Figure Description
[0025] Figure 1 This is a schematic diagram of the overall process of the distributed Hash Join hotspot bucket optimization execution method of the present invention.
[0026] Figure 2 This diagram illustrates the parallel processing of hotspot bucket identification and splitting during the construction phase of the distributed Hash Join hotspot bucket optimization execution method of this invention. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.
[0028] like Figure 1 As shown, the distributed Hash Join hotspot bucket optimization execution method proposed in this invention includes 10 steps in its overall execution process, and the specific implementation method is as follows: I. System Architecture and Basic Data Structures This invention applies to a distributed database cluster, which includes at least one coordinating node and multiple data nodes (DNs). The coordinating node is responsible for receiving SQL queries, generating distributed execution plans, and issuing tasks; the data nodes are responsible for executing local subtasks, including local hash join operations. Each data node contains multiple parallel execution units, which can be local threads, parallel workers, or task instances, used to execute parallel computing tasks.
[0029] This invention maintains a runtime statistics structure, BucketRuntimeStat, for each first-level hash bucket, as defined below: typedef struct BucketRuntimeStat { uint64 tuple_count; uint64 total_bytes; uint32 max_chain_len; uint64 probe_count; uint64 probe_time_ns; uint64 spill_bytes; bool is_hot; BucketRuntimeStat; During the execution of HashJoin, the system updates the above statistical fields in real time as the data basis for hotspot detection.
[0030] In this invention, the local remapping descriptor HotBucketRemapDesc corresponding to hotspot bucket splitting is defined as follows: typedef struct HotBucketRemapDesc { int parent_bucket_no; int split_level; int subbucket_cnt; int hash_family_id; HotBucketRemapDesc; This descriptor fully records the metadata of a single hotspot bucket split, which is used to guide the secondary hash mapping of data between the construction side and the probe side.
[0031] The detailed execution steps are as follows: Step S1: Issue a local Hash Join task: After receiving the equi-join query request submitted by the user, the coordinating node generates a distributed execution plan through the query optimizer and distributes the local Hash Join subtask to multiple data nodes within the cluster. Each data node, upon receiving the task, initiates the Hash Join operator execution process in its local executor. The distributed execution plan can be a remote sub-plan, an executable plan tree, or other execution description, as long as the data node executor can recognize the Hash Join node and inject the runtime optimization logic of this invention.
[0032] Step S2: Construct the first-level hash bucket: Within a single data node, the executor selects the input table with the smaller data volume as the construction side (inner table) and the other input table as the probe side (outer table) according to the general rules of Hash Join. For each record on the construction side, the join key is extracted and the first-level hash value is calculated. The record is then written into the corresponding first-level bucket according to the hash value, ultimately forming a local hash table containing N first-level buckets. The first-level buckets can be organized using a bucket head array plus chained collisions, or other equivalent hash table structures; this invention does not limit this approach.
[0033] Step S3: Collect runtime statistics for bucket-level operations During the hash table construction and probing matching phases, the system continuously updates the statistical fields in the Bucket Runtime Stat for each first-level bucket: Build phase: For each record written, update the corresponding bucket. 、 and update the conflict chain length. If a spill is triggered, then update. .
[0034] Exploration phase: Update each bucket visited. and the cumulative detection time probe_time_ns If a spill is triggered during the probing phase, updates will be performed synchronously. .
[0035] Based on the above statistical indicators, the system calculates a comprehensive load score for each bucket. The calculation formula is:
[0036] in , , , , The weighting coefficient is configurable; the default value can be set to [value]. =0.3、 =0.3、 =0.2、 =0.15、 =0.05, which can be adjusted according to the business scenario. For indicators that are not selected or have not yet generated valid data in the current statistical stage, the corresponding weight is 0. This indicates the number of records in the current first-level bucket after the first-level hash calculation is performed on the construction end; This indicates the cumulative number of bytes in the current first-level bucket after the first-level hash calculation is performed on the construction end; This represents the length of the collision chain that contains the most tuples among the collision chains formed due to hash collisions. This represents the cumulative number of tuples that the probe has mapped and accessed after the first-level hash calculation. This metric counts the number of probes that have entered the bucket. This represents the cumulative number of bytes written to temporary storage due to insufficient available memory for hash join. When no disk overflow occurs, this metric is 0. The function uses mean normalization, taking the average of the corresponding metrics of all first-level buckets of the current data node as the benchmark. The calculation method is as follows:
[0037] This represents the arithmetic mean of the same metric across all first-level buckets in the current Hash Join operator on the current data node; when the mean is 0, the normalization result is 0. Through this comprehensive score, the system can quantify the degree of bucket load anomalies from multiple dimensions.
[0038] Step S4, Hotspot bucket determination: The system employs a joint judgment rule combining fixed and relative thresholds to periodically detect hotspots in all first-level buckets. The judgment period is configurable, for example, once every 10,000 records processed. A bucket is marked as a target hotspot bucket when any of the following conditions are met: Relative record count threshold: Number of records in the bucket >Average number of records in the bucket × K1, where K1 is a preset multiplier, which can be 3 by default. 5; Memory threshold: Cumulative bytes within the bucket The single-bucket memory budget threshold, which can be configured based on node memory and the number of buckets; Conflict chain threshold: Maximum length of a conflict chain >L, where L is a preset chain length threshold, for example, 100; Detection threshold: Detection phase >Average number of detections × K2, or probe_time_ns >Average detection time × K2, where K2 can be 3 by default; Overall scoring threshold: >S, where S is a preset comprehensive threshold, such as 2.5.
[0039] If no hotspot buckets are identified, all first-level buckets are ordinary buckets, and the system performs subsequent join processing along the traditional Hash Join path without entering the secondary splitting process.
[0040] Step S5: Generate local remapping descriptors: Once the target hotspot bucket is identified, the system immediately generates a HotBucketRemapDesc structure for that bucket, fills in the original bucket number, the splitting level as 2, the second-level hash function family ID, and determines the number of subbuckets, subbucket_cnt.
[0041] The number of sub-buckets is dynamically adjusted: first, the base level is determined based on the overall score of the hotspot buckets or a multiple of the number of records, for example: When the number of records in the hotspot bucket is 3 times the average number of records in the bucket When the multiplier is 5, the number of sub-buckets is 4; When the number of records in the hotspot bucket is 5 times the average bucket When the multiplier is 10, the number of sub-buckets is 8; When the number of records in the hotspot bucket is more than 10 times that of the average bucket, the number of sub-buckets is 16.
[0042] Meanwhile, the number of sub-buckets does not exceed the number of idle parallel execution units of the current data node, ensuring that each sub-bucket can be allocated an independent execution unit. If there are insufficient idle execution units, the nearest power of 2 is taken as the number of sub-buckets.
[0043] Step S6, Hotspot bucket second-level hash split: Based on the local remapping descriptor, the system performs a second-level hash mapping on all existing construction-side records within the hotspot bucket. The second-level hash function belongs to the same hash family as the first-level hash function, but uses a different hash seed or a different bitwise operation to avoid correlation with the first-level hash and ensure even splitting. The formula for calculating the sub-bucket number is:
[0044] in For the second-level hash function, For the connection key value of the record, The number of sub-buckets is configured; through this calculation, all records in the original hotspot bucket are redistributed to multiple sub-buckets, completing the secondary split.
[0045] If the split is triggered during the build phase, the remaining build-side records that have not been written to the first-level bucket will be directly written to the corresponding sub-bucket through the second-level hash calculation, without having to go through the first-level bucket again, thus reducing data copying overhead.
[0046] Step S7: Add the child bucket to the local task queue: After the split is complete, all sub-buckets are added to the local task scheduling queue of the current data node as independent Hash Join subtasks, waiting to be picked up and processed by the parallel execution unit. Ordinary buckets do not enter this queue and are still processed by the original execution path.
[0047] Step S8: The local parallel execution unit processes the sub-buckets: The data node scheduler distributes the sub-bucket tasks in the queue to multiple idle parallel execution units. Each execution unit is responsible for the complete Hash Join process of one sub-bucket, including building the sub-bucket hash table (if incomplete), receiving records from the probe side and performing matching, and outputting the join result. Records from the probe side corresponding to the original hot bucket are also distributed to the corresponding sub-buckets for matching according to the second-level hash rule.
[0048] This step prioritizes parallel processing within the current data node, avoiding the distribution of sub-buckets to other data nodes and thus preventing cross-node data transfer and scheduling overhead.
[0049] Step S9: Summarize the sub-bucket join results: After all sub-buckets have been processed, each parallel execution unit outputs the connection results of the sub-buckets to the result aggregation module. The aggregation module merges the results of all sub-buckets under the same original hot spot bucket to form the complete connection result of that hot spot bucket.
[0050] Step S10: Summarize and output the final results: The join results of the hotspot bucket are merged with the join results of all regular buckets to obtain the local join result of the current data node, which is then returned to the upper-level node. Finally, the coordinating node or the upper-level summarizing node aggregates the local results of all data nodes to generate the final result set of the query and returns it to the user.
[0051] Specific examples: Hotspot bucket splitting during the build phase: This embodiment addresses the hotspot bucket scenario caused by skewed data volume on the construction side, such as... Figure 2 As shown.
[0052] For example, consider the following query: select from t_order o join t_customer c on o.cust_id = c.cust_id; Where t_customer is the customer details table (a non-dimensional table, with multiple records corresponding to the same cust_id), which is used as the building side (inner table) to build the hash table; t_order is the order fact table, which is used as the probing side (outer table) to probe the hash table.
[0053] On a specific data node, the system divides the construction-side records into 8 first-level buckets according to the first-level hash rule. During the construction process, the number of records in each bucket is counted in real time. bucket0 Each bucket in bucket 6 contains approximately 1 million records, with an average of about 4.63 million records per bucket. Bucket7 contains 30 million records, which is 6.5 times the average number of records per bucket, exceeding the preset multiple threshold of 5. At the same time, its comprehensive load score exceeds the threshold, so it is identified as a hot bucket.
[0054] The system generates a local remapping descriptor for bucket7 and sets the number of sub-buckets to 8 (to match the 8 idle parallel execution units of the current node). Then, it performs a second-level hash split on the 30 million records in bucket7, resulting in 8 sub-buckets from bucket7-0 to bucket7-7.
[0055] After the split, there are 8 parallel execution units PE0 Each PE7 is responsible for the hash join processing of one sub-bucket. The order records of the corresponding bucket 7 on the probe side are also distributed to the corresponding sub-bucket for matching according to the second-level hash rule. The huge bucket that was originally processed by a single execution path has been split into 8 sub-buckets that can be processed in parallel, which greatly reduces the processing time and eliminates the long tail of execution.
[0056] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0057] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0058] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A distributed Hash Join hotspot bucket optimization method, characterized in that, Includes the following steps: S1. The coordinating node distributes the local Hash Join task in the distributed execution plan to multiple data nodes, and each data node executes the local Hash Join task in its local executor. S2. Within a single data node, select the data on the construction side and calculate the hash value of the connection key according to the first-level hash rule. Map the construction side records into multiple first-level buckets to form a local hash table. S3. During the hash table construction phase or the probe matching phase, continuously collect and update the bucket-level runtime statistics of each first-level bucket in real time. S4. Based on the preset hotspot determination conditions, detect the runtime statistics of each first-level bucket to determine whether there is a target hotspot bucket that meets the hotspot conditions. If no hotspot bucket is identified, all first-level buckets are treated as ordinary buckets and the join process is performed along the original HashJoin path. S5. If a target hotspot bucket is identified, a local remapping descriptor is generated for the target hotspot bucket, and the configuration parameters required for splitting are recorded. S6. Based on the local remapping descriptor, perform the second-level hash mapping only on all records in the target hotspot bucket to complete the secondary split of the hotspot bucket; S7. After splitting, multiple sub-buckets are formed, and the processing tasks of each sub-bucket are added to the local task queue of the current data node. S8. Schedule multiple local parallel execution units within the current data node to each receive and execute the Hash Join processing task of the corresponding sub-bucket. S9. After all sub-buckets have been processed, summarize the sub-bucket connection results output by each parallel execution unit to obtain the overall connection result of the hot spot bucket. S10. The overall connection results of the hotspot bucket and the connection results of all ordinary buckets are summarized in a unified manner, and the local connection results of the current data node are output. Finally, the upper-level node summarizes the local connection results of all data nodes to generate the final query result.
2. The distributed Hash Join hotspot bucket optimization execution method according to claim 1, characterized in that: The bucket-level runtime statistics mentioned in step S3 include the number of records in the bucket, the cumulative number of bytes in the bucket, the maximum length of the conflict chain, the bucket memory usage, the number of probe accesses, the cumulative probe time, the number of spilled bytes, and the number of spills. The system calculates a comprehensive load score for each first-level bucket. The calculation formula is: in , , , , For configurable weighting coefficients, This means that the corresponding indicator will be normalized according to the average value of all first-level buckets in the current data node; This indicates the number of records in the current first-level bucket after the hash calculation is performed on the construction end. This indicates the cumulative number of bytes in the current first-level bucket after the first-level hash calculation is performed on the construction end; This represents the length of the collision chain that contains the most tuples among the collision chains formed due to hash collisions. This represents the cumulative number of tuples that the probe has mapped and accessed after the first-level hash calculation. This metric counts the number of probes that have entered the bucket. This represents the cumulative number of bytes written to temporary storage due to insufficient available memory for hash join. When no disk overflow occurs, this metric is 0. The comprehensive load score serves as the core basis for hotspot determination in step S4.
3. The distributed Hash Join hotspot bucket optimization execution method according to claim 1, characterized in that: The preset hotspot determination condition in step S4 adopts a joint determination combining a fixed threshold and a relative threshold. The first-layer bucket is determined to be the target hotspot bucket when any one of the following conditions is met: The number of records in the bucket exceeds a preset multiple of the average number of records in all first-level buckets of the current data node; The cumulative number of bytes in the bucket exceeds the preset single-bucket memory budget threshold; The maximum length of the hash collision chain within the bucket exceeds the preset chain length threshold. The cumulative number of detections or the cumulative detection time of the detection phase bucket exceeds the preset detection number threshold or the preset detection time threshold; The overall load score of the bucket exceeds the preset overall score threshold.
4. The distributed Hash Join hotspot bucket optimization execution method according to claim 1, characterized in that: The local remapping descriptor mentioned in step S5 contains at least four pieces of information: the original bucket number, the split level identifier, the second-level hash function identifier, and the number of sub-buckets. In step S6, the second-level hash mapping is still based on the join key calculation, but it uses a different bit selection rule or mapping space than the first-level hash. The sub-bucket number is calculated as follows: in For the second-level hash function, For the connection key value of the record, The number of sub-buckets configured.
5. The distributed Hash Join hotspot bucket optimization execution method according to claim 4, characterized in that: The number of sub-buckets Dynamically adjust based on the hotspot level of the hotspot bucket and the current node resource status: When the number of records in the hotspot bucket is a first multiple of the number of records in the average bucket, the number of sub-buckets is set to the first tier value; when the number of records in the hotspot bucket is a second multiple of the number of records in the average bucket, the number of sub-buckets is set to the second tier value, wherein the value in the second multiple is greater than the value in the first multiple, and the value in the second tier is greater than the value in the first tier. At the same time, the number of sub-buckets is matched with the number of idle parallel execution units of the current data node, ensuring that each sub-bucket can be assigned to an independent execution unit for processing.
6. The distributed Hash Join hotspot bucket optimization execution method according to claim 1, characterized in that: Steps S3 and S4 are executed in real time during the hash table construction phase: During the process of writing build-side data to the first-level bucket in batches, the runtime statistics of each bucket are updated synchronously. When the build-side load metric of any bucket exceeds the hotspot threshold, the secondary splitting process is immediately triggered. Records already written to the hotspot bucket are remapped and split, and the remaining unwritten build-side records are directly written to the corresponding sub-buckets according to the second-level hash rules, without needing to be written to the first-level bucket before splitting.
7. The distributed Hash Join hotspot bucket optimization execution method according to claim 1, characterized in that: Steps S3 and S4 are executed in real time during the detection and matching phase: When the load metrics of all first-level buckets do not reach the hotspot threshold during the construction phase, but during the probing phase, the probing side records concentrated access to some first-level buckets, resulting in the number of probing accesses and the cumulative probing time of the corresponding buckets being significantly higher than those of other buckets, the buckets of this type are identified as hotspot buckets based on the runtime statistics of the probing phase and a second split is triggered; after the split is completed, subsequent probing records are directly distributed to the corresponding sub-buckets for matching according to the second-level hash rules.
8. The distributed Hash Join hotspot bucket optimization execution method according to claim 1, characterized in that: In step S6, when performing a secondary split on the hotspot bucket, a hotspot key-aware splitting method is used: First, scan all build-side records in the hotspot bucket, count the frequency of each connection key value, and classify the connection key values whose frequency exceeds the key frequency threshold into hotspot key set, and the rest into non-hotspot key set; divide the records corresponding to the hotspot key set into at least one logical sub-bucket, and divide the records corresponding to the non-hotspot key set into multiple ordinary sub-buckets according to the second-level hash rule, and then hand them over to different parallel execution units for processing.
9. The distributed Hash Join hotspot bucket optimization execution method according to claim 1, characterized in that: When the memory usage of a hotspot bucket exceeds the threshold and triggers a spill operation, an independent spill mechanism for sub-buckets is used: After the second-level hash split is completed, each sub-bucket is independently spilled to an independent file segment on the disk, and each sub-bucket corresponds to a dedicated spill storage area; during readback processing, the sub-buckets are loaded into memory in segments, and the corresponding parallel execution units are independently responsible for the readback and join matching operations of the sub-bucket spill files.
