As we saw in Chapter 1, representing complex data like text, images, or audio as high-dimensional vectors (embeddings) allows us to capture semantic meaning. However, the databases we typically use for application development, such as relational databases (like PostgreSQL, MySQL) or even many NoSQL databases (like MongoDB, Cassandra), weren't originally built for the primary task these vectors demand: finding the most similar vectors to a given query vector based on geometric distance or orientation.
Think about a standard SQL query: SELECT * FROM products WHERE category = 'electronics' AND price < 500
. This relies on exact matches or comparisons on scalar values organized in structured rows and columns. Traditional indexes, like B-trees, are highly effective for these operations. Searching for text often involves inverted indexes that map keywords to documents.
Vector search operates differently. The fundamental query isn't about matching exact values but finding "neighbors" in a high-dimensional space. Given a query vector q, we want to find data vectors p in the database that minimize a distance function, like the Euclidean distance:
d(p,q)=i=1∑n(pi−qi)2or maximize a similarity function, such as cosine similarity:
similarity(p,q)=∥p∥∥q∥p⋅qPerforming this calculation exhaustively against millions or billions of high-dimensional vectors (where n, the dimensionality, can be hundreds or thousands) is computationally infeasible for real-time applications. This is where vector databases come in.
So, what defines a vector database?
At its core, a vector database is a database system specifically designed and optimized for the storage, indexing, and querying of high-dimensional vector embeddings alongside, typically, associated metadata.
Key distinguishing characteristics include:
In essence, while traditional databases are optimized for filtering and retrieving structured data based on exact matches or range comparisons, vector databases are optimized for finding approximate matches in high-dimensional vector spaces based on similarity. They provide the necessary infrastructure to build applications like semantic search, recommendation engines, image retrieval systems, and anomaly detection, which depend heavily on understanding relationships encoded within vector embeddings.
The following sections will examine the internal architecture, data models, and specific operations that enable these capabilities.
© 2025 ApX Machine Learning