← Back to list
Database
#다차원색인#R-Tree#KD-Tree#Quad-Tree#공간DB#134회
Last updated · 2026-09-30

Multidimensional Index Structures

1. Overview

A. Definition

An index structure designed to efficiently search multidimensional data of two or more dimensions, such as location, spatial, and multi-attribute data. It hierarchically partitions and clusters the space itself so that range queries, nearest-neighbor (NN) queries, and spatial containment/overlap queries can be processed quickly.

In one sentence, a multidimensional index is "a data structure that narrows the search space by considering coordinates on several axes simultaneously." If a conventional index is a dictionary that lines up values in size order on a single line, a multidimensional index is closer to an atlas that divides a map into regions. Just as we go straight to the Gangnam page rather than comparing every café in Seoul one by one when looking for "cafés within a 1 km radius of Gangnam Station," a multidimensional index prunes away entire regions of space irrelevant to the query region, reducing search cost.

The queries such structures handle fall into three broad kinds. First is the range query, which finds objects that fall inside a rectangular (hyper-rectangular) region, such as "all points within latitude 37.4–37.5 and longitude 127.0–127.1." Second is the nearest-neighbor query, which finds the k objects closest to a given point (kNN). Third is the spatial relationship query, which determines the containment, intersection, or adjacency of two shapes. All three rely on the common property of "proximity between coordinates," and a multidimensional index reflects this proximity directly in the physical storage structure.

B. Background and Necessity

The reason conventional indexes like the B-Tree are unsuitable for multidimensional data is fundamental. A B-Tree sorts values by a total order along a single axis (one dimension) and searches by magnitude comparison. However, for a query that must satisfy several axes simultaneously, such as "find points whose latitude and longitude are both within a certain range," the very premise of a total order does not hold. (A point with greater latitude is not necessarily a "closer" point.) Even if you place a one-dimensional index on each axis, after narrowing candidates by one axis you must ultimately scan the remaining axes exhaustively (filtering), so selectivity drops and the performance gain is marginal.

Spatial data, by its very nature, defines the relationship of "near/contains" through the proximity of multidimensional coordinates. Therefore, an index is needed that reflects this proximity in the storage structure itself, hierarchically partitioning and clustering the space. Industrial demand reinforced this. Map and navigation services became mainstream, multimedia search that converts images and audio into feature vectors spread, and decisively, LLM-based RAG (retrieval-augmented generation) and recommendation systems made high-dimensional embedding vector search essential infrastructure. Today, the multidimensional index has expanded beyond "geographic space" into a foundational technology that also handles "semantic space."

2. Overall Structure and Types

Multidimensional indexes are broadly divided, according to their philosophy of dividing space, into data partitioning methods and space partitioning methods. The former wraps and groups where the actual data resides, so it adapts to the data distribution (R-Tree family); the latter divides the space itself regularly, so it is simpler to implement and also explicitly represents empty space (Quad-Tree, Grid File, KD-Tree). The concept diagram below shows this taxonomy.

flowchart TB
  M["Multidimensional Index Structure"] --> DP["Data Partitioning"]
  M --> SP["Space Partitioning"]
  DP --> T1["R-Tree / R*-Tree (MBR hierarchy)"]
  DP --> T2["SS-Tree / SR-Tree (sphere / sphere+MBR)"]
  SP --> S1["KD-Tree (alternating-axis binary split)"]
  SP --> S2["Quad-Tree / Oct-Tree (quad/oct split)"]
  SP --> S3["Grid File (multidimensional grid)"]
  M --> AP["Approximate Methods (high-dimensional)"]
  AP --> A1["IVF (cluster-based)"]
  AP --> A2["HNSW (graph-based)"]
  style AP fill:#e8f0fe,stroke:#2f6fed,stroke-width:2px

A. R-Tree / R*-Tree — the de facto standard of spatial DBs

The R-Tree is a balanced tree that generalizes the B-Tree to multiple dimensions, grouping upward the Minimum Bounding Rectangle (MBR) that wraps each object hierarchically. Leaf nodes hold the MBRs of actual objects, while upper nodes hold larger MBRs that again wrap the lower MBRs. During a query, it descends only the branches whose MBRs overlap the query region, so most of the space can be cut away at once.

The R-Tree's weakness is that sibling MBRs may overlap. When overlap is large, a single query must traverse several branches at once, inflating the number of search paths. The improvement is the R*-Tree, which minimizes not only MBR area but also overlap and margin during node insertion and splitting, and on insertion failure forcibly reinserts some entries (forced reinsertion) to raise tree quality. In empirical benchmarks, the R*-Tree shows substantial performance gains over the R-Tree in range queries, so it has been adopted as the default index of commercial spatial DBs such as PostGIS and Oracle Spatial.

It is especially strong for spatial objects with area or volume (building outlines, road polylines, administrative-boundary polygons) and for range queries. For example, PostGIS's GiST index internally uses R-Tree-family algorithms and answers "road segments intersecting this polygon" in milliseconds rather than seconds.

B. KD-Tree — point data and NN search

The KD-Tree (k-dimensional tree) is a structure that binary-partitions space, alternating axes (x-axis → y-axis → … → x-axis). Each internal node represents one splitting hyperplane and divides points into left/right subtrees by that criterion. It is efficient for nearest-neighbor search of point data, because if the hypersphere whose radius is the current best distance from the target point does not overlap the opposite subspace, that branch can be pruned entirely.

However, the KD-Tree easily loses balance under dynamic insertion/deletion, and as dimensionality rises, its partitioning effect drops sharply. Beyond just a few dozen dimensions, NN search essentially converges to an exhaustive scan (see the curse of dimensionality below). So the KD-Tree is mainly used for low-dimensional (2–10-dimensional) point sets, such as position estimation in robotics or 3D point-cloud processing.

C. Quad-Tree / Grid File — space partitioning and grids

The Quad-Tree recursively partitions 2D space into four quadrants, subdividing only the regions where data exists, so it is advantageous when data is sparse and uneven (a map where empty ocean and dense downtown coexist). Extended to three dimensions it becomes the Oct-Tree, used for collision detection in game engines and voxel rendering.

The Grid File divides space into multidimensional grid buckets and maps each bucket to a disk page. It provides near-constant-time access when data is uniformly distributed, but has the weakness that under skewed distribution certain buckets become overcrowded and performance collapses.

The table below summarizes the core differences among the four types. Still, it is only an aid; the actual choice must be made after first analyzing the data distribution and the dominant query pattern.

Type Partitioning method Strength Weakness / fit
R-Tree/R*-Tree MBR hierarchy grouping (data partitioning) Area objects, range queries, balanced tree Degrades on MBR overlap, spatial-DB standard
KD-Tree Alternating-axis binary split Low-dimensional point NN search Degrades in high dimensions, dynamic imbalance
Quad-Tree Recursive quadrant split Sparse, uneven 2D data 3D uses Oct-Tree, depth variance
Grid File Multidimensional grid buckets Constant access under uniform distribution Bucket overcrowding under skew

3. Search Principles and Selection Criteria

A. The search process of range and NN queries

The search of a multidimensional index proceeds in two stages: filter and refinement. First the index quickly screens candidates by approximate boundaries such as MBRs or grids (filter stage), and then verifies only those candidates with actual geometric operations (exact distance/intersection computation) (refinement stage). Thanks to these two stages, expensive precise operations are applied only to a small number of candidates, reducing total cost.

The NN query adds a branch-and-bound technique on top. It uses the k-th nearest distance found so far as an upper bound, and if the distance to a node's minimum boundary (MINDIST) is larger than this bound, it does not visit that node at all. Visiting nodes in order of smallest MINDIST via a priority queue can greatly reduce unnecessary accesses. Below is the processing flow of an R-Tree-based range query.

flowchart TB
  Q["Input query region (range / point+k)"] --> R["Visit root node"]
  R --> C{"Does child MBR overlap<br/>the query region?"}
  C -->|"No"| P["Prune (skip that subtree)"]
  C -->|"Yes"| D{"Is it a leaf node?"}
  D -->|"No"| R2["Descend into that child"]
  R2 --> C
  D -->|"Yes"| F["Filter: gather candidate object MBRs"]
  F --> RF["Refine: verify with exact geometric operations"]
  RF --> RES["Return results"]
  P --> RES

B. Selection criteria

Which structure is optimal depends on the nature of the data and queries, and choosing wrong makes the index a burden instead. If the data type is points with only coordinates, a KD-Tree is natural; if it is area objects with area or volume, an MBR-based R-Tree is natural. Which structure is favorable diverges depending on whether the query type is a range query, nearest neighbor, or spatial containment. The number of dimensions is especially important: beyond a few dozen to a few hundred dimensions, tree indexes are neutralized by the curse of dimensionality described below, so one must pivot to approximation (ANN). If the data distribution is uniform, a Grid File is better; if skewed, a tree structure that adapts to density is better.

Criterion Consideration
Data type Points (KD-Tree) vs. area/objects (R-Tree)
Query type Whichever of range, NN, spatial containment dominates
Number of dimensions Low-dimensional tree vs. high-dimensional approximation (ANN)
Distribution Uniform (Grid File) vs. skewed (tree family)
Dynamism Frequency of insertion/deletion (R*-Tree is strong on dynamic data)

4. Use Cases

Multidimensional indexes underlie every service that "quickly finds what is near." In spatial DBs/GIS, "restaurants within 1 km of me" or "buildings contained in this administrative district" are found instantly with an R-Tree. Nearby search in domestic services such as KakaoMap and TMAP, and the "nearest store" sorting of delivery apps, are representative; internally they use PostGIS or Elasticsearch's geo_point index (BKD-Tree, a disk variant of the KD-Tree). Elasticsearch/Lucene in fact apply the BKD-Tree to numeric and geographic fields to accelerate large-scale range queries.

In multimedia search, images are converted to feature vectors and similar images are found by NN; in OLAP, range aggregations over multidimensional cubes are accelerated. But today's largest application is AI vector search. OpenAI's text-embedding-3 and domestic embedding models convert text into vectors of typically 768–3072 dimensions, and in such ultra-high dimensions the tree structures above are neutralized. So vector DBs such as Pinecone, Milvus, pgvector, and FAISS adopt approximate-nearest-neighbor (ANN) algorithms like HNSW and IVF instead of trees. This is the core engine of RAG, semantic search, and recommendation systems.

Field Use Representative technology
Spatial DB/GIS Nearby search, area queries (location services) PostGIS (GiST/R-Tree), BKD-Tree
Multimedia Image/feature-vector similarity (NN) search KD-Tree, Product Quantization
OLAP Range aggregation over multidimensional cubes Grid File, R-Tree
AI vector search High-dimensional embedding ANN HNSW, IVF-PQ (FAISS/Milvus)

5. Deep Dive — the curse of dimensionality and the evolution toward vector search

The key to understanding multidimensional indexes is the curse of dimensionality. As the dimension d grows, the volume of the hyperspace in which the data resides expands exponentially, so a finite set of data points grows ever farther apart and all inter-point distances become similar. When the ratio of the nearest-neighbor distance to the farthest-neighbor distance converges to 1, the very concept of "near" blurs, the query hypersphere overlaps almost every node, and the tree's pruning effect disappears. Empirically, beyond roughly 10–20 dimensions the performance of KD-Trees and R-Trees drops to the level of a linear scan.

There are two directions to breach this wall. One is dimensionality reduction, indexing after leaving only the intrinsic dimensions via PCA or an autoencoder. The other is approximate nearest neighbor (ANN), which gives up a little accuracy to gain speed. Representatively, IVF (Inverted File) clusters vectors with k-means and then searches only the few clusters near the query, combining this with PQ (Product Quantization) (IVF-PQ) to store vectors compressed. HNSW (Hierarchical Navigable Small World) moves greedily along neighbors in a hierarchical graph, providing near-logarithmic-time search, and has become the de facto standard of vector DBs. In other words, a division of roles has settled in: traditional tree-based multidimensional indexes handle low-dimensional spatial data, while graph- and cluster-based ANN handle high-dimensional semantic vectors.

Another notable trend is integration into relational DBs. PostgreSQL's pgvector extension officially added support for HNSW indexes through 2024–2025, so embedding search can be performed inside SQL without a separate vector DB. This can be seen as the process by which the multidimensional index is absorbed from a specialized system's preserve into a standard feature of general-purpose DBMSs.

6. Considerations and Implications (Professional Engineer's Perspective)

  1. An index is not free — the trade-off of storage and update cost. A multidimensional index accelerates lookups but incurs tree-reconstruction and reinsertion costs on insertion, deletion, and update. If writes are frequent and the lookup pattern is simple, the index may actually increase total cost, so the read/write ratio of the workload must be analyzed first.
  2. The choice of structure by dimension and distribution governs performance. The same data can differ dozens of times in performance depending on the structure chosen. One should establish a design principle mapping low-dimensional area objects to R*-Tree, low-dimensional points to KD-Tree, uniform distributions to Grid File, and high-dimensional embeddings to HNSW/IVF.
  3. In high dimensions, "accurate enough + fast" is more practical than "exact." In services where latency governs the user experience, like RAG and recommendation, ANN at a recall level of 95–99% is overwhelmingly more advantageous than a fully accurate exhaustive search. Tuning the trade-off between recall and QPS (queries per second) via parameters (ef_search, nprobe) is a practical competency.
  4. The combination of hybrid search and filtering is the crux. In practice, one must apply not only vector similarity but also metadata filters (price, category, period) and keywords (BM25) together. Balancing the accuracy-performance trade-off of pre-filtering vs. post-filtering, and designing the combination of spatial and vector indexes, are central challenges of next-generation search architecture.
  5. Strategically leverage the trend of integration into relational DBs. Given the trend of indexes being absorbed into existing DBMSs like pgvector, for small and mid-sized services it may be more reasonable in terms of total cost of ownership (TCO) to leverage a multidimensional index within the existing stack rather than bearing the operational burden of introducing a separate vector DB.

References


In one line: Multidimensional index structures such as R-Tree, KD-Tree, Quad-Tree, and Grid File hierarchically partition space to accelerate range and NN queries over multidimensional data in two stages of filter and refinement; they are chosen to fit the data/query type and the number/distribution of dimensions, but because of the curse of dimensionality they evolve in high dimensions into vector search (ANN) like HNSW and IVF, becoming the core infrastructure of RAG and recommendation.