IMPLEMENTATION OF AN INDEXED METHOD FOR SEARCHING SIMILAR VECTORS IN DATABASES
Abstract
This paper addresses the performance bottleneck of cosine-similarity search in large vector datasets stored in database systems. A conventional approach computes cosine similarity between a query vector and every dataset vector and then ranks the results, which is costly for high dimensionality and, when data reside on disk, for I/O. We propose a lightweight two-stage indexing scheme. First, we build an auxiliary table of 2M unit “anchor” vectors (orths) whose coordinates are zero everywhere except one axis with value +1 or −1. During offline preprocessing, each dataset vector is assigned the identifier of the anchor vector with the smallest cosine distance, and this identifier is stored as an index field. At query time, we compute cosine similarity between the query and all anchors and select the top L anchors (or those above a threshold). Then the DBMS retrieves only rows whose stored anchor id matches the selected anchors, leveraging standard index structures such as B-trees or bitmap indexes. Exact cosine ranking is performed only within this reduced subset. The resulting complexity is reduced by approximately M/L compared with a full scan, while also cutting disk accesses. In experiments on a 384-dimensional text-embedding database of about 500,000 vectors (paraphrase-multilingual-MiniLM-L12-v2), using L = 7 decreased search time from ~16 s to ~0.5 s, providing an observed 30–40× speed-up. The approach is easy to integrate into DB pipelines and suits large-scale text retrieval.
Fields of Study & Subjects
Advanced Image and Video Retrieval Techniques
Data Management and Algorithms
Advanced Database Systems and Queries
Publication details
- Journal / source
- Vestnik komp iuternykh i informatsionnykh tekhnologii
- Issue
- 259
- Pages
- 12–12
- Publication date
- 1 January 2026
- Language
- EN