Lesson 4 of 5 Text Preparation, Embeddings and Vector Databases

Choosing a Vector Database on AWS

This lesson explains the AWS vector database options, which store embeddings with metadata and return the most similar vectors, and how to choose one from a scenario's specifications.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe vector search in Amazon OpenSearch Service.
  • Use pgvector on RDS and Aurora PostgreSQL.
  • Identify Amazon S3 Vectors and other stores.
  • Choose a vector database for a requirement.

Amazon OpenSearch Service

OpenSearch Service supports k-NN vector search alongside full-text search, so a single query can combine keyword relevance (BM25) and vector similarity in hybrid search. It is available as managed domains, where you size instances, shards and replicas, and as OpenSearch Serverless vector search collections, which scale capacity automatically. It suits low-latency, high-query-rate applications, hybrid search and rich filtering, and is the default vector store for Bedrock Knowledge Bases quick creation.

Scenario questions

Domain or Serverless?

Exam skills 1.1.7

Choose between OpenSearch Service managed domains and OpenSearch Serverless.

Log in to try this activity Interactive activities are free with an account.

PostgreSQL with pgvector

The pgvector extension adds a vector data type and similarity search operators to Amazon RDS for PostgreSQL and Amazon Aurora PostgreSQL. Vectors are stored in ordinary tables alongside relational data, so a single SQL query can join, filter and rank by similarity, with transactional consistency between vectors and the business data they describe.

pgvector suits teams already running PostgreSQL, which avoids adding and operating another database, and applications in which vectors and business data change together, such as product descriptions and their embeddings. Aurora PostgreSQL is also a supported vector store for Amazon Bedrock Knowledge Bases.

Amazon S3 Vectors and other stores

Amazon S3 Vectors adds vector buckets and vector indexes to S3. It stores up to two billion vectors per index with sub-second query latency, no infrastructure and the lowest storage cost, which suits large collections queried infrequently, such as archives and long-tail RAG content. Amazon Neptune Analytics combines graph and vector search for GraphRAG. Amazon DocumentDB and Amazon ElastiCache also offer vector search for teams already using them.

The following table summarises the choice.

RequirementBest fit
Hybrid keyword and vector search, high query rate, low latencyOpenSearch Service or Serverless
Vectors next to relational data with SQL joinsRDS or Aurora PostgreSQL with pgvector
Very large, infrequently queried collection at lowest costAmazon S3 Vectors
Relationships between entities (GraphRAG)Neptune Analytics
No vector infrastructure decisions for a quick RAG prototypeKnowledge base quick create (OpenSearch Serverless or S3 Vectors)

The following diagram matches three teams' needs, a high-traffic chatbot, an order system on Aurora and a large legal archive, to a vector store for each.

Three vector stores for three needs. The high-rate customer chatbot with product codes in questions uses OpenSearch Serverless with hybrid search; the order system on Aurora uses pgvector to join similar products with stock levels in one query; and the 900-million-clause legal archive searched a few times a day uses S3 Vectors.
The scenario is illustrative.
Sort into groups

Choose the vector store

Exam skills 1.1.7

Choose the vector store that fits each team's requirement.

Log in to try this activity Interactive activities are free with an account.
Worked example

Three teams, three stores

Three teams in one company describe their needs.

Team needChoiceReason
Customer chatbot, 2 million chunks, 200 queries per second, product codes in questionsOpenSearch Serverless with hybrid searchLow latency at high rate; keyword matching for codes
Order system on Aurora PostgreSQL wants similar-product suggestions joined with stock levelsAurora PostgreSQL with pgvectorOne SQL query joins vectors with inventory
Legal archive of 900 million clauses searched a few times a dayAmazon S3 VectorsLowest cost at very large scale with sub-second queries

Forcing all three onto one store would either overpay for the archive or add latency and complexity for the chatbot.

Check yourself

Which vector store suits vectors that must be joined with relational data in transactions?

Show answer

pgvector on RDS or Aurora PostgreSQL.

Exam Tips

Remember for the exam

  • Hybrid search and high query rates: OpenSearch Service.
  • Vectors with relational joins and transactions: pgvector on RDS or Aurora PostgreSQL.
  • Huge, rarely queried vector sets at lowest cost: S3 Vectors.
  • Graph relationships plus vectors: Neptune Analytics (GraphRAG).
  • Index dimensions must equal the embedding model's output dimensions.