Vector databases for AI: MLA-C02 study notes and practice questions
What to know about Vector databases for AI for the MLA-C02 exam, from the Data Preparation for ML and AI domain (28% of the exam guide), then 1 free question to test it. Part of the MLA-C02 study guide.
Vector store questions ask where to keep embeddings for RAG or semantic search, given the team’s existing data, scale, latency and cost.
AWS options
Store
Strengths
OpenSearch Serverless (vector collection)
The default quick-create store for Bedrock knowledge bases; no clusters; supports hybrid search (vector plus keyword) and metadata filters
OpenSearch Service (managed clusters)
k-NN search with control over engines and index settings; full-text and log search in the same place
Aurora PostgreSQL / RDS for PostgreSQL with pgvector
Vectors next to relational data, so one SQL query can filter, join and search; good when the team already runs PostgreSQL
Amazon S3 Vectors
Very low cost for large vector sets that are queried less often, with subsecond queries
Neptune Analytics
Graph plus vectors, used for GraphRAG in knowledge bases
MemoryDB
Very low-latency in-memory vector search
DocumentDB
Vector search alongside JSON documents
Bedrock knowledge bases also support third-party stores such as Pinecone, Redis Enterprise Cloud and MongoDB Atlas.
Concepts
Similarity metrics: cosine, Euclidean (L2) or dot product; use the one the embedding model recommends.
Approximate nearest neighbor (ANN) indexes such as HNSW trade a little recall for much faster search; IVF suits very large sets with less memory.
Dimensions must match the embedding model (for example, Titan Text Embeddings V2 supports 256, 512 or 1,024). Changing the model means re-embedding everything.
Metadata filtering narrows the search to matching documents, such as one customer or one product line.
Choosing
“Already on Aurora PostgreSQL and needs joins with existing tables”: pgvector.
“Serverless, managed by the knowledge base, hybrid search”: OpenSearch Serverless.
“Billions of vectors, lowest cost, latency not critical”: S3 Vectors.
Common traps
Adding a second database when the existing PostgreSQL can hold vectors.
Mixing embedding models in one index.
Ignoring metadata filters and relying on prompts to exclude other customers’ data.
A public library system stores its catalog and branch records in an Amazon Aurora PostgreSQL cluster. The search team has computed embeddings for 12 million book descriptions and wants patrons to run semantic search.
Each query must return the nearest matches in under a second, and the results must be filtered by branch and then joined to catalog tables. The team wants to avoid operating a second database to keep in sync with the catalog.
Which solution meets these requirements?
Choose one answer.
AA. Store the embeddings in the existing Aurora PostgreSQL cluster with the pgvector extension, and run one SQL query that combines vector distance, branch filters and joins.
BB. Index the embeddings in an Amazon OpenSearch Service domain with the k-NN plugin, and copy the branch records into OpenSearch for filtering.
CC. Store the embeddings as Amazon S3 Vectors indexes and run a Lambda function that filters results by branch and joins them to the catalog in application code.
DD. Store each embedding as a list attribute in an Amazon DynamoDB table and compute cosine similarity in a Lambda function for every query.
D. Wrong: Scoring every item on each query cannot meet a one-second target for 12 million vectors. DynamoDB also cannot join the results to the relational catalog tables.
Explanation
Aurora PostgreSQL with pgvector lets the team run vector search, branch filters and joins in one SQL query against the data it already has. OpenSearch and S3 Vectors are capable vector stores, but each adds a second system that must be kept in sync with the catalog. Scanning vectors in DynamoDB cannot meet the latency target at this scale.
Want more on Vector databases for AI? The 5 full-length practice sets have 9 more Vector databases for AI questions, 325 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →