Efficient High-Dimensional ANN Search
Efficient High-Dimensional ANN Search
22, 50, 57, 70, 79, 80, 83, 93, 94, 99, 100, 106, 107, 113], and graph- SuCo achieves top performance (best for hard datasets) even when
based [6, 33, 34, 67, 71, 110]. However, each method has its own compared to methods that do not provide theoretical guarantees.
advantages and disadvantages. LSH-based methods are well-known Our main contributions are summarized as follows.
for their robust theoretical guarantees on the quality of results, but
• We design SC-score, a metric that we show follows the Pareto
they have to pay a high cost in terms of query answering time and
principle on commonly used real-world datasets, demon-
have a large memory footprint [104]. VQ-based methods use the
strating that SC-score can act as a proxy for the Euclidean
clustering structure as the index, so the index memory footprint is
distance between data points.
small, but a lot of indexing time is required to compute fine-grained
• We present Subspace Collision (SC), a novel ANN search
clusters [9]. Tree-based methods can partition data points into dif-
framework based on SC-score. Our experiments show that
ferent regions by splitting nodes, but as the space dimensionality
the subspace collision framework can achieve high recall for
increases, the effectiveness of trees decreases [17, 101], and query
ANN search. We perform rigorous mathematical analysis
performance is thus limited. Graph-based methods typically have
showing that the subspace collision framework can provide
better query efficiency, but take considerably more time to construct
theoretical guarantees on the quality of its results.
indexes and require a larger memory footprint [31, 54]. The reason
• We propose SuCo (code available online [102]), which achieves
is that graph-based methods need to identify the near neighbors
efficient and accurate ANN search based on our subspace col-
for each data point in the dataset (and connect to them) during the
lision framework. We design a clustering-based lightweight
indexing phase, while in the query phase, they only need to search
index to ensure excellent indexing performance, and design
on a gradually converging path. Thus, no existing ANN method
query strategies to ensure excellent query performance.
performs well in both indexing and query answering performance,
• We conduct extensive experiments, demonstrating that both
while providing rigorous theoretical guarantees for the quality of
the indexing and query answering performance of SuCo out-
the answers.
performs state-of-the-art ANN methods that can provide
Our Method. In this paper, we propose a novel ANN search
theoretical guarantees, performing 1-2 orders of magnitude
framework called Subspace Collision (SC) and design an index struc-
faster query answering with only up to one-tenth of the
ture and query strategy for this framework, forming an efficient and
index memory footprint. Moreover, SuCo achieves top per-
accurate method named SuCo [102]. Compared to other ANN meth-
formance (best for hard datasets) even when compared to
ods, SuCo performs well in both indexing performance (in terms
methods that do not provide theoretical guarantees.
of time and memory footprint) and query performance and has
rigorous theoretical guarantees. Moreover, we first design SC-score,
a metric that we show follows the Pareto principle (also known 2 RELATED WORK
as the 80/20 rule) on many commonly used real-world datasets LSH-based methods. Locality-sensitive hashing (LSH)-based meth-
(Figure 2), demonstrating that data points closer to the query point ods are known for their theoretical guarantees on the quality of re-
tend to have larger SC-scores. As such, SC-score can act as a proxy turned query results [3, 4, 36, 43, 52, 59, 63, 65, 87, 91, 104, 111, 112].
for the Euclidean distance between data points. Second, inspired A family of LSH functions is used to map data points from the orig-
by SC-score, we present a novel ANN search framework called inal high-dimensional space to low-dimensional projected spaces.
“Subspace Collision (SC)” (cf. Section 3) that is different from the The properties of LSH can ensure that data points that are closer
existing LSH-based, VQ-based, tree-based, and graph-based frame- in the original space are also closer in the projected space [39].
works. We design a naive method (without index structure) called For this reason, all that is needed to obtain high-quality results
SC-Linear, which achieves extremely high recall (over 0.99) on real- is to examine the points around the query point in the projected
world datasets (cf. Table 2), illustrating the effectiveness of the spaces [27]. LSH-based methods improve query efficiency by de-
subspace collision framework for ANN search. Third, we propose signing the index structure and query strategy in the projected
SuCo (cf. Section 4), which achieves efficient and accurate ANN spaces. Based on the query strategy, there are three categories
search by designing an index structure and query strategies for the of LSH-based methods: boundary constraint [3, 61, 89, 91], colli-
subspace collision framework. SuCo constructs lightweight indexes sion counting [36, 43, 52, 63, 65], and distance metric [87, 111].
by clustering data points in each subspace and using the inverted DET-LSH [104] is the state-of-the-art LSH-based method, which
multi-index (IMI) to reduce the clustering complexity. We further combines the ideas of boundary constraint and distance metric.
design a new query algorithm for IMI, called Dynamic Activation VQ-based methods. Vector quantization is a lossy data com-
(cf. Algorithm 3), which improves the query efficiency by up to 40% pression technique that encodes vectors from a high-dimensional
over the original query algorithm. Fourth, we perform a rigorous space into a finite set of values from low-dimensional discrete sub-
mathematical analysis, showing that the proposed subspace colli- spaces [40, 41]. Vector Quantization (VQ)-based methods aim to
sion framework can provide theoretical guarantees on the quality minimize the quantization distortion, which is the sum difference be-
of its results (cf. Theorems 1 and 2). Fifth, we conduct extensive tween each data point and its approximation [54]. Based on the way
experiments on real-world datasets. Numerical results show that of combining quantizers among multiple subspaces, there are four
SuCo outperforms state-of-the-art ANN methods that can provide categories of VQ-based methods: product quantization (PQ) [45],
theoretical guarantees in indexing and query answering perfor- additive quantization (AQ) [8], composite quantization (CQ) [109],
mance, performing 1-2 orders of magnitude faster query answering and tree quantization (TQ) [10]. PQ is the most popular VQ-based
with only up to one-tenth of the index memory footprint. Moreover, methods, which divide the original high-dimensional space into a
Cartesian product of many low-dimensional subspaces and then
Subspace Collision: An Efficient and Accurate Framework for High-dimensional Approximate Nearest Neighbor Search SIGMOD ’25, June 22–27, 2025, Berlin, Germany
...
...
...
...
...
...
...
...
...
(a) Data points distribution, where the (b) Nearest neighbors when choosing 𝑥 or 𝑦 dimension (c) Nearest neighbors when intro-
Euclidean distance from 𝑂 1 to 𝑂 10 to as the subspace for measuring similarity. ducing the idea of collision based on
the query point 𝑞 gradually increases. 𝑥 and 𝑦 subspaces, where the colli-
sion ratio 𝛼 = 0.5.
Figure 1: Illustration of finding nearest neighbors using the idea of subspace and collision.
quantizes subvectors in each subspace separately [68]. Many exten- is still one of the state-of-the-art graph-based method [92], which
sions have been proposed to improve the performance of PQ for in- has an industrial-grade library and is therefore widely used.
dex construction and query answering [9, 11, 38, 46, 48, 69, 74, 105].
Although both PQ and subspace collision framework divide the 3 SUBSPACE COLLISION FRAMEWORK
high-dimensional space into subspaces, their design concepts are
3.1 Framework Design
different. PQ sums the distances between quantized data points and
the query in all subspaces to judge similarity, while the subspace Intuitively, two data points that are close in the high-dimensional
collision framework counts the number of collisions between data original space are also more likely to be close in its random subspace.
points and the query in all subspaces to judge similarity. Optimized Given a dataset D of 𝑛 data points in 𝑑-dimensional space and a
Product Quantization (OPQ) [38] using the inverted multi-index [9] query 𝑞 ∈ R𝑑 , and 𝑜 1∗, . . . , 𝑜𝑘∗ are the 𝑘-NNs of 𝑞 in D. Suppose we
is the state-of-the-art VQ-based method [31, 68]. randomly select 𝑠 dimensions from all 𝑑 dimensions as a subspace
Tree-based methods. Tree-based methods hierarchically par- (𝑠 < 𝑑), and the points 𝑜 1∗, . . . , 𝑜𝑘∗ and 𝑞 in this subspace are denoted
tition the high-dimensional space and group similar data points as 𝑜 1∗′, . . . , 𝑜𝑘∗′ and 𝑞 ′ . Then, it is expected that statistically, the prox-
into the same partition as leaf nodes [97]. The partitioning process imity of 𝑜 1∗′, . . . , 𝑜𝑘∗′ and 𝑞 ′ is greater than other points in D. The
is usually recursive, so the root node of the tree covers the entire above intuition is based on the premise that the distances between
high-dimensional space, and its children nodes cover disjoint sub- data points are relatively evenly distributed in each dimension. If
spaces. Based on the way of partitioning, there are three categories the distance between two points is concentrated in some dimen-
of tree-based methods: pivoting [19, 21, 108], hyperplane [14, 20, 22, sions, the above intuition may not hold. As shown in Figure 1(a)
26, 29, 32, 51, 58, 70, 81–83, 86, 93, 95, 96, 99, 107, 114] and compact and Figure 1(b), if we choose the 𝑥 dimension as the subspace for
partitioning [15, 35, 73]. Hyperplane partitioning is the most popu- measuring distance, 𝑂 5 is the nearest neighbor because its distance
lar tree-based method, which recursively partitions the space by from the query point 𝑞 is only distributed in the 𝑦 dimension. Simi-
the hyperplane with random direction or axis-aligned separating larly, if we choose the 𝑦 dimension as the subspace for measuring
hyperplane. Annoy [14] is the state-of-the-art tree-based method distance, 𝑂 3 and 𝑂 6 are the nearest neighbors since their distances
with balanced indexing and query answering performance [54]. to 𝑞 are mostly distributed in the 𝑥 dimension. Points like 𝑂 1 and
Graph-based methods. Graph-based methods construct a prox- 𝑂 2 , which are close to 𝑞 but their distances evenly distributed in
imity graph where each node represents a data point, and edges both 𝑥 and 𝑦 dimensions, are easily missed.
represent the neighbor relationships between data points [7, 90, 92]. We need to design a framework to solve the above problems,
The main idea of graph-based methods is “a neighbor’s neighbor is which meets two requirements:
likely also to be a neighbor”. Compared with other types of meth- • Req1: combine multiple subspaces to alleviate significant
ods, graph-based methods typically have better query efficiency errors that a single subspace may cause;
but require considerably more time to construct indexes [31, 54]. • Req2: reduce the impact of distance ranking within a single
The reason is that graph-based methods need to identify the near subspace on the final result.
neighbors for each data point in the dataset (and connect to them)
To this end, we first define “collision” and “subspace collision”.
during the indexing phase, while in the query phase, they only need
to search on a gradually converging path. Based on the way of build- Definition 1 (Collision). Given a dataset D of 𝑛 data points in
ing the proximity graph, there are three categories of graph-based 𝑑-dimensional space, a query point 𝑞 ∈ R𝑑 , and a collision ratio
methods: cluster and merge [71], iterate from an initial graph [23, 𝛼 ∈ (0, 1), if a data point 𝑜 ∈ D satisfies: ∥𝑜, 𝑞∥ is one of the
28, 33, 34, 54, 84], consecutive insertion [6, 64, 66, 67, 110]. Although minimum 𝛼 · 𝑛 distances between all 𝑛 data points and 𝑞, i.e., 𝑜 is
there have been some innovative works subsequently, HNSW [67] one of the (𝛼 · 𝑛)-NNs of 𝑞 in D, we say that 𝑜 collides with 𝑞.
SIGMOD ’25, June 22–27, 2025, Berlin, Germany Jiuqi Wei, Xiaodong Lee, Zhenyu Liao, Themis Palpanas, and Botao Peng
(c) Microsoft SPACEV10M: 𝑑 =100, (d) Microsoft Turing-ANNS10M: 𝑑 =100, 3.3 Preliminary Experiments
𝑁𝑠 =10, 𝑠 =10, 𝛼 =0.1 𝑁𝑠 =10, 𝑠 =10, 𝛼 =0.1 In this section, we conduct preliminary experiments to determine
whether the subspace collision framework is effective. On the one
Figure 2: “Pareto principle” of SC-score on four datasets. hand, we explore whether SC-score is a good measure of the dis-
Each figure contains 𝑛 = 10M (107 ) scatter points, the scatter tance between all data points and the query point. On the other
(𝑖, 𝑗) represents the average SC-score of the 𝑖-th NN for 1000 hand, we measure the performance of the SC-Linear algorithm to
queries is 𝑗, where 𝑖 = 1, 2, . . . , 107 , and 𝑗 ∈ [0, 𝑁𝑠 ]. see whether it can return high-quality query results. More detailed
experiments and parameter learning will be given in Section 5.3.
3.3.1 Effectiveness of SC-score. We select 1000 queries and count
initialized to record the SC-score of each data point (line 1). Then, the SC-score of all data points in the dataset under each query. We
use Definition 3 to sample and obtain 𝑁𝑠 subspaces, and divide all perform this statistical analysis on multiple commonly used ANN
data points and the query point into these subspaces, where 𝑜 𝑖𝑗 and datasets. Due to space limitations, we only show the results on four
𝑞𝑖 represent the 𝑗-th data point and 𝑞 in the 𝑖-th subspace (lines datasets in Figure 2 (other results are similar).
2-3). In practice, for convenience, we can divide the 𝑑-dimensional We can see from Figure 2 that SC-score follows the “Pareto
principle” and is insensitive to the data distribution. Data points
space into 𝑁𝑠 subspaces of the same length 𝑠 = 𝑁𝑑𝑠 , where the 𝑖-th
that are close to the query point have a high SC-score. Then, as the
subspace is allocated from the (𝑠 · (𝑖 −1) +1)-th to (𝑠 ·𝑖)-th dimensions
distance increases, the SC-score decreases rapidly until a “turning
in the original space, 𝑖 = 1, . . . , 𝑁𝑠 . This division method can be
point” is reached. After the “turning point”, the SC-score decreases
regarded as a special case of Definition 3. In order to count the SC-
slowly with the distance. The sharp change in trend makes each
score of each data point, it is necessary to calculate the Euclidean
figure look like an “L” shape.
distance between each data point and 𝑞 in each subspace (lines
The “Pareto principle” of SC-score makes it very suitable for
4-6). For each subspace 𝑆𝑖 , sort the distances and select 𝛼 · 𝑛 points
ANN search. In all four datasets, the x-axis of the “turning point”
closest to 𝑞𝑖 as collisions, and increase the SC-score of these points
is about 0.2𝑛, which means that the 20% of data points closest to
by one, where 𝛼 is the collision ratio (lines 7-10). To further improve
the query have a large and distinguishable SC-score, while the
query accuracy, we design a re-ranking mechanism (lines 11-15).
remaining 80% of the data points have a small and indistinguishable
Specifically, sort the SC-scores of all points and select 𝛽 · 𝑛 points
SC-score. Therefore, we only need to select data points with a
with the largest SC-scores as candidates, where 𝛽 is the re-rank
large enough SC-score before the “turning point” to obtain high-
ratio (lines 11-13). Calculate the Euclidean distance between all
quality ANN search results. SC-Linear is designed based on this idea.
candidates and 𝑞 in the original space, and return the top-𝑘 points
Specifically, the re-ranking mechanism (lines 11-15 in Algorithm 1)
closest to 𝑞 (lines 14-15). To facilitate understanding of SC-Linear,
selects 𝛽 · 𝑛 data points with the largest SC-scores as candidates
readers can refer to Figure 3 (the workflow of SuCo method). The
and then returns the top-𝑘 data points closest to the query among
difference between SC-Linear and SuCo is that SC-Linear does not
these candidates. Experimental results in Section 3.3.2 demonstrate
construct the inverted multi-indexes to speed up query answering.
that SC-Linear can return high-quality ANN results.
The experimental results in Section 3.3.2 show that SC-Linear has
high query accuracy, which demonstrates the effectiveness of our 3.3.2 Performance of SC-Linear. To measure whether SC-Linear
designed subspace collision framework. Theorem 2 in Section 3.4 can return high-quality results, we perform ANN search when 𝑘=50
provides a theoretical guarantee on the quality guarantee of results on four datasets (𝑁𝑠 and 𝑠 set for each dataset are the same as that
SIGMOD ’25, June 22–27, 2025, Berlin, Germany Jiuqi Wei, Xiaodong Lee, Zhenyu Liao, Themis Palpanas, and Botao Peng
𝑗 𝑗
in Figure 2). Table 2 shows the average recall of 100 queries. We can random variable 𝑍 1 − 𝑍 2 is of zero mean and variance 2𝜎 2 , it then
see that SC-Linear can support accurate ANN search with extremely follows from Chebyshev’s inequality that, for any 𝑡 > 0,
high recall, demonstrating that the subspace collision framework 𝑗 𝑗
Pr (|𝑍 1 − 𝑍 2 | ≥ 𝑡) ≤ 2𝜎 2 /𝑡 2, (4)
we designed is very suitable for ANN search. Furthermore, when
the parameters 𝑁𝑠 and 𝛼 are set reasonably, SC-Linear can still have and thus
a high recall even if a very small re-rank ratio 𝛽 is used. This also
|𝑍 1 − 𝑍 2 | ≤ (𝑁𝑠 − 𝐶 − Δ)𝑡 .
Í 𝑗 𝑗
0≤ 𝑗 ∈ S¬𝐶 (5)
confirms the rule that “data points closer to query point tend to have
larger SC-scores”. More detailed parameter learning on 𝛼, 𝛽, and 𝑁𝑠 ′
For scenario (ii), we have, for some 𝑡 > 0 and a given 𝑗,
will be given in Section 5.3. √︁
0 ≤ 𝑍 1 ≤ (1 − 𝛼)(𝜎 2 + 𝑚 2 ), Pr (|𝑍 2 − 𝑚| ≥ 𝑡 ′ ) ≤ (𝜎/𝑡 ′ ) 2 .
𝑗 𝑗
...
�-dimensional Clustering id
alf
... s Inverted Multi-Index
with a collision ratio 𝛼 ∈ (0, 1). rs th with �2 cells for �1
... Fi ... ids
�-dimensional t ro
(ii) By Chebyshev’s inequality that, for any 𝑡 > 0, �1 K-Means cen
...
Clustering K
...
... Second half ...
... of �1
𝑗 2 2
Pr (|𝑍𝑖 − 𝑚| ≥ 𝑡) ≤ 𝜎 /𝑡 . (10)
...
...
...
...
... First half
... ...
of ��� K-Means K ce
We thus have that Raw Dataset �� � ntro
...
...
Clustering id
... ... s
√︁ Se Inverted Multi-Index
2
(𝑁𝑠 − 𝐶) (𝑚 − 𝑡) ≤ ∥𝑧𝑖 ∥ ≤ 𝐶 (1 − 𝛼)(𝜎 2 + 𝑚 2 ) + (𝑁 − 𝐶)(𝑚 + 𝑡), co with �2 cells for ���
𝑠 of nd ... ids
�� hal K-Means t ro
f cen
...
Clustering K
holds with probability at least 1 − (𝑁𝑠 − 𝐶)𝜎 2 /𝑡 2 . In the following, �
...
without loss of generality, we only discuss here the case where the
= 𝑁𝑠 , for which we should have 𝑘
re-rank ratio 𝛽 is chosen so that 𝐶 √︁ Divide �� subspaces Generate Inverted Multi-Index for each subspace
and 𝛽 both small, and ∥𝑧𝑖 ∥ 2 ≤ 𝑁𝑠 (1 − 𝛼)(𝜎 2 + 𝑚 2 ). Other scenar- (a) Index construction.
ios with 𝐶 < 𝑁𝑠 can be similarly studied by increasing 𝛽 accordingly.
In this setting, we show in the following, that the �-dimensional
√︁ obtained range of ... Inverted Multi-Index
Result
1st
the squared Euclidean distance ∥𝑧𝑖 ∥ 2 ∈ (0, 𝑁𝑠 (1 − 𝛼)(𝜎 2 + 𝑚 2 )] �-dimensional �1 with �2 cells for �1 Collisions in �1
Candidates 2nd
is indeed among the top-𝑘 smallest in a set of 𝑛 samples, with a ... Collision Rerank
Counting
...
...
3rd
Query
���
...
controlled probability. The moments and joint distribution of the ... Inverted Multi-Index Collisions in ���
with �2 cells for ��� k-th
top-𝑘 ordered (e.g., smallest) values in a set of 𝑛 i.i.d. samples has
been extensively studied in the literature of order statistics [1, 2].
Divide query Count collisions Re-rank and return top-k
For the simplicity of exposition, we discuss here the case where into subspaces in all subspaces candidates as the result
the squared distances are normally distributed ∥𝑧𝑖 ∥ 2 ∼ N (𝑁𝑠 𝑚, 𝑁𝑠 𝜎 2 )
(which, as we shall see below, admits closed-form approximation for (b) Query answering.
moments and leads to an explicit control of the success probability
as a function of all tuning parameters). To treat general (e.g., non- Figure 3: Overview of the SuCo workflow.
Gaussian) distributions, it suffices to replace the (approximations
of) first and second moments in (11) and (12) using PDF and CDF
of the specific distribution. In the normal case, the expectation of be chosen (within a range) to achieve an optimal “computation-
the 𝑘-th order statistic (i.e., the expected value of the 𝑘 smallest accuracy trade-off.” This is consistent with the choice of 𝛼, 𝛽 in
value) in a set of 𝑛 sample with 𝑛 large is approximately given by the proofs of Theorems 1 and 2 above, and with our experimental
√︁ 𝑘 −𝛾 conclusions in Section 5.3.3.
𝐸𝑘,𝑛 = 𝑁𝑠 𝑚 + 𝑁𝑠 𝜎 2 · Φ −1 , 𝛾 = 0.375, (11)
𝑛 − 2𝛾 + 1
and variance approximately given by 4 THE SUCO METHOD
−2 As analyzed in Section 3.2 and Section 3.3, SC-Linear’s query effi-
𝑘 (𝑛 − 𝑘 + 1) −1 𝑘
𝑉𝑘,𝑛 = 𝑁𝑠 𝜎 2 · 𝜙 Φ , (12) ciency is limited because when counting collisions in each subspace,
(𝑛 + 1) 2 (𝑛 + 2) 𝑛+1 it is necessary to calculate the Euclidean distance between the query
with 𝜙 (·) and Φ(·) the PDF and CDF of standard Gaussian distri- and all data points (lines 4-10 in Algorithm 1). Therefore, the prob-
bution. These approximations are known to be rather accurate as lem that needs to be solved is transformed into “how to find the
long as 𝑛 ≥ 9, see [13, 16]. Thus, it follows again from Cheby- 𝛼 · 𝑛 data points closest to the query in each subspace as quickly and
shev’s inequality that the probability
√︁ of correct answering is at least accurately as possible.”
1−𝑉𝑘,𝑛 /𝑡 2 for 𝑡 such that 𝑡 > 𝑁𝑠 𝑚 (1 − 𝛼)(1 + 𝜎 2 /𝑚 2 ) −𝐸𝑘,𝑛 . Tak- In this section, we propose SuCo to accelerate collision counting
√ 𝑘 (𝑛−𝑘+1)
−1 in each subspace by building lightweight indexes and designing
ing 𝑁𝑠 and 𝛼 ∈ (0, 1) and 𝑡 = 2𝑁𝑠 𝜎𝑛 𝑛 𝜙 Φ −1 𝑛+1 𝑘 ,
query strategies. Figure 3 provides a high-level overview of the
we conclude that the probability of correct answering is at least SuCo workflow, including index construction and query answering.
1/2. This concludes the proof of Theorem 2. □
The proof of Theorem 1 relies on the idea that in cases where 4.1 Index Construction
“subspace collision” happens for both or neither of the two subvec- To count collisions as quickly and accurately as possible, i.e., find
tors, their Euclidean distance should be approximately the same; the 𝛼 · 𝑛 data points closest to the query in each subspace, we need
while in cases where “subspace collision” happens for one but not to construct an index in each subspace, which should be able to
the other, their distance should differ by a significant amount, mak- quickly locate data points around the query.
ing the overall distance different. A similar argument holds for a There are two requirements for the index structure: (1) The
single data in the proof of Theorem 2. Intuitively, larger values of index structure should be lightweight enough. The index needs
collision ratio 𝛼 and re-rank ratio 𝛽 lead to higher computational to be constructed independently in all 𝑁𝑠 subspaces, and 𝑁𝑠 is 6-
complexity, while too small 𝛼 and 𝛽 reduce the accuracy of the pro- 12 in practice. If the index structure is complex, it requires a long
posed approach. As a consequence, the parameters 𝛼 and 𝛽 should indexing time and a large memory footprint to construct 𝑁𝑠 indexes.
SIGMOD ’25, June 22–27, 2025, Berlin, Germany Jiuqi Wei, Xiaodong Lee, Zhenyu Liao, Themis Palpanas, and Botao Peng
1000
500
500
1000
(a) K-means clustering with inverted index. K-means clustering is (b) K-means clustering with inverted multi-index. K-means clustering
√
performed in the 2D space. The inverted index holds 𝐾 2D centroids is performed in each dimension. The inverted multi-index holds 𝐾
(red stars in the figure). 1D centroids for each dimension. 𝐾 2D clusters are obtained through
Cartesian product of 1D clusters.
Figure 4: Illustration of K-means clustering (𝐾=16) in 2D space using inverted index or inverted multi-index.
Therefore, the graph-based and tree-based indexes that are currently Algorithm 2: Create Index
popular in ANN search are no longer applicable. (2) The query Input: A dataset D, dataset size 𝑛, dimensionality of data
method for collision counting needs to be simple and fast enough. points 𝑑, subspace number 𝑁𝑠 , number of K-means
Collision counting needs to be performed in all 𝑁𝑠 subspaces, so the clusters 𝐾, number of K-means iterations 𝑡
query speed of the index for each subspace needs to be fast enough. Output: Centroid list 𝑐𝑒𝑛𝑡𝑟𝑜𝑖𝑑𝑠 and inverted multi-index
Fortunately, we don’t need to obtain few (usually 𝑘 ∈ [1, 100]) list 𝐼𝑀𝐼𝑠
but accurate query results like graph-based and tree-based indexes. 1 Initialize a list 𝑐𝑒𝑛𝑡𝑟𝑜𝑖𝑑𝑠 of length 2𝑁𝑠 and a list 𝐼𝑀𝐼𝑠 of
We only need to find many (𝛼 · 𝑛, usually 𝛼 ∈ [0.01, 0.1]) but not length 𝑁𝑠 ;
necessarily accurate data points as collisions. 2 Divide the 𝑑-dimensional space into 𝑁𝑠 subspaces:
Clustering-based indexes can meet the above two requirements. 𝑆 1 , 𝑆 2 , . . . , 𝑆 𝑁𝑠 ;
The index structure is lightweight enough because only the cluster 3 Divide all data points into 𝑁𝑠 subspaces: D1 , . . . , D𝑁𝑠 ;
centroids and data point assignments for each cluster need to be
4 for 𝑖 = 1 to 𝑁𝑠 do
recorded. The query method for collision counting is simple and
5 Initialize a map 𝐼𝑀𝐼𝑖 as the inverted multi-index;
fast enough because only the distance between the query and each
6 Further divide 𝑆𝑖 into two subspaces 𝑆𝑖1 and 𝑆𝑖2 ;
centroid needs to be calculated. Each centroid can represent all data
7 Divide D𝑖 into two subspaces: D𝑖1 and D𝑖2 ;
points in its cluster, and if the centroid is close enough to the query, √
all data points within the cluster can be considered to collide with 8 𝑐𝑒𝑛𝑡𝑟𝑜𝑖𝑑𝑠𝑖1, 𝑎𝑠𝑠𝑖𝑔𝑛𝑚𝑒𝑛𝑡𝑠𝑖1 ← call Kmeans(D𝑖1, 𝐾, 𝑡);
√
the query. Ordinary K-means clustering uses an inverted index to 9 𝑐𝑒𝑛𝑡𝑟𝑜𝑖𝑑𝑠𝑖2, 𝑎𝑠𝑠𝑖𝑔𝑛𝑚𝑒𝑛𝑡𝑠𝑖2 ← call Kmeans(D𝑖2, 𝐾, 𝑡);
store which data points are in each cluster. However, to achieve 10 𝑐𝑒𝑛𝑡𝑟𝑜𝑖𝑑𝑠.𝑎𝑝𝑝𝑒𝑛𝑑 (𝑐𝑒𝑛𝑡𝑟𝑜𝑖𝑑𝑠𝑖1, 𝑐𝑒𝑛𝑡𝑟𝑜𝑖𝑑𝑠𝑖2 );
fine-grained indexing, many clusters need to be constructed (𝐾 is 11 for 𝑗 = 0 to 𝑛 − 1 do
large), which will restrict indexing and query answering efficiency. 12 𝐼𝑀𝐼𝑖 [𝑎𝑠𝑠𝑖𝑔𝑛𝑚𝑒𝑛𝑡𝑠𝑖1 [ 𝑗], 𝑎𝑠𝑠𝑖𝑔𝑛𝑚𝑒𝑛𝑡𝑠𝑖2 [ 𝑗]].𝑎𝑝𝑝𝑒𝑛𝑑 ( 𝑗);
The inverted multi-index (IMI) [9] replaces the vector quantization
13 𝐼𝑀𝐼𝑠.𝑎𝑝𝑝𝑒𝑛𝑑 (𝐼𝑀𝐼𝑖 );
inside the inverted index of K-means with the product quantiza-
tion [45]. Figure 4 shows the difference between K-means clustering 14 return 𝑐𝑒𝑛𝑡𝑟𝑜𝑖𝑑𝑠 and 𝐼𝑀𝐼𝑠;
using the inverted index and the inverted multi-index. In Figure 4(a),
K-means clustering is performed in the 2D space, and the inverted
index holds 𝐾=16 2D centroids and the IDs of all data points belong- Figure 3(a) shows the workflow of SuCo to construct the index,
ing to each cluster. In Figure 4(b), K-means clustering is√performed and Algorithm 2 gives the pseudocode. First, we need to initialize
in each dimension, and the inverted multi-index holds 𝐾 = 4 1D two lists, one to store the centroids obtained by clustering in each
centroids for each dimension and the IDs of all data points belong- subspace (the first part of our index) and the other to store the in-
ing to the cluster. Then, 𝐾=16 2D clusters can be obtained through verted multi-indexes constructed in each subspace (the second part
the Cartesian product of 1D clusters. Therefore, given the number of our index) (line 1). Then, we divide the 𝑑-dimensional original
of clusters 𝐾, K-means clustering using the inverted multi-index
√ space into 𝑁𝑠 subspaces (𝑆 1, 𝑆 2, . . . , 𝑆 𝑁𝑠 ) with 𝑠 = 𝑁𝑑𝑠 dimensions,
can reduce the time complexity from O (𝐾 ·𝑛 ·𝑑 ·𝑡) to O ( 𝐾 ·𝑛 ·𝑑 ·𝑡) and divide all data points into each subspace (lines 2-3). Assume
compared to using the inverted index, 𝑡 is the number of iterations. without loss of generality that 𝑠2 is an integer. For each subspace,
based on the product quantization concept of IMI, we further divide
Subspace Collision: An Efficient and Accurate Framework for High-dimensional Approximate Nearest Neighbor Search SIGMOD ’25, June 22–27, 2025, Berlin, Germany
each 𝑠-dimensional subspace into two 𝑠2 -dimensional subspaces �����1 0.4 0.6 1.0 1.5 1.8 �����2 0.3 0.6 1.1 1.3 1.6
(lines 4-7). Although each subspace can be divided into more than
���1 0 1 2 3 4 ���2 0 1 2 3 4
two parts, both the IMI paper [9] and our experiments show that
retrieved
dividing each space into two parts achieves the best performance.
Then, for 𝑆𝑖 , we perform K-means clustering on all data points in round cluster active_idx active_dists
two 𝑠2 -dimensional subspaces (𝑆𝑖1 and 𝑆𝑖2 ) to obtain the centroids 0 none 0 0.7
of clusters 𝑐𝑒𝑛𝑡𝑟𝑜𝑖𝑑𝑠𝑖1, 𝑐𝑒𝑛𝑡𝑟𝑜𝑖𝑑𝑠𝑖2 and the data point assignments
(belongs to which cluster) 𝑎𝑠𝑠𝑖𝑔𝑛𝑚𝑒𝑛𝑡𝑠𝑖1, 𝑎𝑠𝑠𝑖𝑔𝑛𝑚𝑒𝑛𝑡𝑠𝑖2 (lines 8-9). 1 (0,0) 1 0 1.0 0.9
We put all the obtained centroids into a list as the first part of our 2 (1,0) 1 1 0 1.0 1.2 1.3
index (line 10). To improve query efficiency, in each subspace 𝑆𝑖 ,
we use the obtained 𝑎𝑠𝑠𝑖𝑔𝑛𝑚𝑒𝑛𝑡𝑠𝑖1, 𝑎𝑠𝑠𝑖𝑔𝑛𝑚𝑒𝑛𝑡𝑠𝑖2 to construct a map 3 (0,1) 2 1 0 1.5 1.2 1.3
𝐼𝑀𝐼𝑖 as the inverted multi-index, and we put all the obtained IMIs 4 (1,1) 2 2 0 1.5 1.7 1.3
into a list as the second part of our index (lines 11-13). Finally, the
centroids and IMI lists are returned as the SuCo indexes. 5 (2,0) 2 2 1 0 1.5 1.7 1.6 1.8
the IMI of each subspace; (2) how to combine the collisions of IMIs 3 𝑎𝑐𝑡𝑖𝑣𝑒_𝑖𝑑𝑥 [0] ← 0;
in all subspaces to obtain the final ANN result. 4 𝑎𝑐𝑡𝑖𝑣𝑒_𝑑𝑖𝑠𝑡𝑠 [0] ← 𝑑𝑖𝑠𝑡𝑠 1 [𝑖𝑑𝑥 1 [0]] + 𝑑𝑖𝑠𝑡𝑠 2 [𝑖𝑑𝑥 2 [0]];
The Multi-sequence algorithm was proposed with IMI to query 5 while TRUE do
IMI and obtain data points that are close to the query [9]. How- 6 𝑝𝑜𝑠 ← index of the minimum element in 𝑎𝑐𝑡𝑖𝑣𝑒_𝑑𝑖𝑠𝑡𝑠;
ever, the Multi-sequence algorithm uses a priority queue to hold 7 𝑐𝑙𝑢𝑠𝑡𝑒𝑟 ← 𝐼𝑀𝐼 [𝑖𝑑𝑥 1 [𝑝𝑜𝑠], 𝑖𝑑𝑥 2 [𝑎𝑐𝑡𝑖𝑣𝑒_𝑖𝑑𝑥 [𝑝𝑜𝑠]]];
the candidate clusters, For the priority queue, both insertion and 8 𝑟𝑒𝑡𝑟𝑖𝑒𝑣𝑒𝑑_𝑐𝑙𝑢𝑠𝑡𝑒𝑟𝑠.𝑎𝑝𝑝𝑒𝑛𝑑 (𝑐𝑙𝑢𝑠𝑡𝑒𝑟 );
popping operations require logarithmic time complexity, which 9 𝑟𝑒𝑡𝑟𝑖𝑒𝑣𝑒𝑑_𝑛𝑢𝑚 += 𝑠𝑖𝑧𝑒𝑜 𝑓 (𝑐𝑙𝑢𝑠𝑡𝑒𝑟 );
is time-consuming. Therefore, we design a new algorithm called
10 if 𝑟𝑒𝑡𝑟𝑖𝑒𝑣𝑒𝑑_𝑛𝑢𝑚 ≥ 𝛼 · 𝑛 then
Dynamic Activation to support query IMI without a priority queue.
11 break;
Dynamic Activation algorithm returns the same query results as √
Multi-sequence algorithm. The experimental results in Section 5.2 12 if 𝑎𝑐𝑡𝑖𝑣𝑒_𝑖𝑑𝑥 [𝑝𝑜𝑠] == 0 and 𝑝𝑜𝑠 < 𝐾 − 1 then
show that the efficiency of Dynamic Activation algorithm is up to 13 𝑎𝑐𝑡𝑖𝑣𝑒_𝑖𝑑𝑥 [𝑝𝑜𝑠 + 1] ← 0;
40% higher than that of the Multi-sequence algorithm. 14 𝑎𝑐𝑡𝑖𝑣𝑒_𝑑𝑖𝑠𝑡𝑠 [𝑝𝑜𝑠 + 1] ←
Algorithm 3 gives the pseudocode of the Dynamic Activation 𝑑𝑖𝑠𝑡𝑠 1 [𝑖𝑑𝑥 1 [𝑝𝑜𝑠 + 1]] + 𝑑𝑖𝑠𝑡𝑠 2 [𝑖𝑑𝑥 2 [0]];
√
algorithm. Given the distances between a query and all centroids in 15 if 𝑎𝑐𝑡𝑖𝑣𝑒_𝑖𝑑𝑥 [𝑝𝑜𝑠] < 𝐾 − 1 then
two subspaces 𝑑𝑖𝑠𝑡𝑠 1, 𝑑𝑖𝑠𝑡𝑠 2 and the indices of sorted distances in 16 𝑎𝑐𝑡𝑖𝑣𝑒_𝑖𝑑𝑥 [𝑝𝑜𝑠]++;
ascending order 𝑖𝑑𝑥 1𝑖 , 𝑖𝑑𝑥 2𝑖 , we need to select one cluster from each 17 𝑎𝑐𝑡𝑖𝑣𝑒_𝑑𝑖𝑠𝑡𝑠 [𝑝𝑜𝑠] ←
subspace to form a cluster in 𝐼𝑀𝐼 . The sum of their distances (one 𝑑𝑖𝑠𝑡𝑠 1 [𝑖𝑑𝑥 1 [𝑝𝑜𝑠]] + 𝑑𝑖𝑠𝑡𝑠 2 [𝑖𝑑𝑥 2 [𝑎𝑐𝑡𝑖𝑣𝑒_𝑖𝑑𝑥 [𝑝𝑜𝑠]]];
from 𝑑𝑖𝑠𝑡𝑠 1 , the other from 𝑑𝑖𝑠𝑡𝑠 2 ) is used as the selection criterion.
The smaller the distance sum of clusters in 𝐼𝑀𝐼 , the earlier they 18 return 𝑟𝑒𝑡𝑟𝑖𝑒𝑣𝑒𝑑_𝑐𝑙𝑢𝑠𝑡𝑒𝑟𝑠;
are retrieved. We first activate a cluster in the first subspace, which
has the minimum distance in 𝑑𝑖𝑠𝑡𝑠 1 (lines 3-4). Activated clusters
can be combined with clusters from the second subspace, and the Figure 5 gives a running example of Algorithm 3. Algorithm 3
two clusters with the minimum sum of distances will be combined runs in a multi-round way, and in each round, it retrieves a cluster
as a retrieved cluster in 𝐼𝑀𝐼 (lines 6-9). When the number of data whose sum of 𝑑𝑖𝑠𝑡𝑠 1 (among the activated indices) and 𝑑𝑖𝑠𝑡𝑠 2 is
points in all retrieved clusters reaches the collision requirement minimal. In the initialization round (round 0), the index 0 of 𝑑𝑖𝑠𝑡𝑠 1
(lines 10-11), the algorithm stops and returns the retrieved clusters is activated (with initial value 0). In round 1, since only index 0
(line 18). Otherwise, we dynamically activate the clusters in the of 𝑑𝑖𝑠𝑡𝑠 1 is activated, the cluster with the joint index of 𝑑𝑖𝑠𝑡𝑠 1 and
first subspace in ascending order of 𝑑𝑖𝑠𝑡𝑠 1 (lines 12-14) and update 𝑑𝑖𝑠𝑡𝑠 2 (0, 0) is retrieved, and its distance to the query is 0.7. Then,
the combination information of the activated clusters (lines 15-17). we activate index 1 of 𝑑𝑖𝑠𝑡𝑠 1 (with initial value 0) and increase the
SIGMOD ’25, June 22–27, 2025, Berlin, Germany Jiuqi Wei, Xiaodong Lee, Zhenyu Liao, Themis Palpanas, and Botao Peng