Learned spatial data partitioning

Keizo Hori, Yuya Sasaki, Daichi Amagata, Yuki Murosaki, Makoto Onizuka · DOI

Abstract

Efficient spatial data partitioning is critical for the performance of distributed spatial database systems. Traditional geometric partitioning methods, such as Quad-trees and KDB-trees, often fail to account for specific query workloads and underlying hardware configurations, leading to suboptimal performance and excessive data shuffling. This paper presents a novel approach that treats spatial partitioning as a Reinforcement Learning (RL) problem. By utilizing Deep Reinforcement Learning (DRL) with specific optimizations like imitation learning and early pruning, the proposed system achieves up to a 59.4% reduction in query workload runtime compared to traditional methods.

Introduction

As spatial datasets—ranging from global GPS logs to urban traffic patterns—continue to grow in scale, distributed systems like Apache Sedona have become essential for processing. A core component of these systems is spatial data partitioning: the process of dividing a map into discrete segments to be processed by individual nodes in a cluster.

Historically, this has been achieved through geometric splitters like Quad-trees or KDB-trees. While effective at balancing data density, these methods are "workload-blind." They do not consider the specific types of queries being executed or the hardware environment, such as the presence of local indices. When partitioning fails to align with query patterns, the system suffers from high communication overhead (shuffling), which significantly degrades performance. This research introduces a "learned" partitioning strategy that adapts to both data distribution and query workloads.

Methodology

The researchers formalize the partitioning task as a Markov Decision Process (MDP) where a DRL agent learns to place boundary lines on a spatial grid to minimize total query runtime.

DRL Architecture

  • State: The environment is represented as a grid map tracking existing boundaries and the density of data points within each cell.
  • Action: The agent can choose to add horizontal or vertical boundary lines to refine the partitions.
  • Reward: The reward function is defined by the squared ratio of the current workload runtime against the best runtime observed during the training process, incentivizing the agent to find increasingly efficient layouts.

Optimization Strategies

To overcome the high computational cost of running real-world queries for every RL step, the authors implemented three key optimizations:

  1. Two-Phase Learning: To avoid the "cold start" problem where an agent makes random, inefficient splits, the model undergoes pre-training. Using imitation learning, the agent is trained to mimic the behavior of established algorithms like KDB-trees before exploring its own strategies.
  2. Grid-Shift Exploration: During the active training phase, the agent utilizes a "grid-shift" mechanism. Instead of purely random exploration, it explores minor adjustments to the current best boundary positions to fine-tune performance.
  3. Early Pruning: To accelerate training, the system monitors the execution of a partitioning layout. If the performance is significantly worse than the current benchmark, the execution is terminated early, saving valuable training time.

Experimental Evaluation

The system was evaluated using three real-world datasets: OSM-US (OpenStreetMap point-of-interest data from the United States), OSM-SA (South America), and Imis (Marine information system data). Each dataset was sampled to 100,000 points. The primary evaluation metric was the runtime of distance join queries, which are computationally intensive and highly sensitive to partitioning quality.

Key Results

  • Performance Gains: The learned partitioning method outperformed the best traditional geometric methods by up to 59.4%.
  • Hardware and Index Awareness: A significant finding was the agent's ability to adapt to hardware configurations. The DRL model learned to create partitions that specifically maximized the utility of local indices, a factor that traditional geometric splitters ignore.
  • Workload Adaptation: The agent successfully optimized for skewed workloads, prioritizing the performance of frequent query types even if it meant slightly lower efficiency for rare queries.
  • Training Efficiency: Through pre-training and pruning, the model reached optimal performance on the US dataset in approximately 65.5 hours. In contrast, versions of the model without these optimizations failed to converge within 120 hours.

Discussion and Future Work

This research demonstrates that spatial partitioning is not merely a geometric problem but a systems optimization problem that benefits significantly from machine learning. By moving away from workload-blind algorithms, distributed spatial databases can achieve substantial performance improvements.

However, several challenges remain. The current model requires a fixed number of partitions to be defined at the outset. Future iterations could allow the agent to determine the optimal number of partitions dynamically. Additionally, while 65 hours is a significant improvement over raw RL, reducing training overhead through transfer learning remains a priority. Finally, extending this approach from point data to more complex geometries, such as polygons and trajectories, represents a vital next step for the field.

Conclusion

Learned spatial data partitioning represents a shift toward self-optimizing database systems. By treating the division of space as a learnable task, this approach provides a robust framework for handling the complexities of modern spatial workloads and hardware environments, offering a clear path toward more efficient big data processing.

Summary updated

BibTeX
@inproceedings{hori2023learned,
  author = {Keizo Hori and Yuya Sasaki and Daichi Amagata and Yuki Murosaki and Makoto Onizuka},
  title = {{Learned spatial data partitioning}},
  booktitle = {aiDM@SIGMOD},
  year = {2023},
  doi = {10.1145/3593078.3593932},
}
Figure