Your average recall hides your smallest customer: build a filtered vector search test on AWS

Your average recall hides your smallest customer: build a filtered vector search test on AWS

Test filtered vector search on DynamoDB, S3 Vectors, OpenSearch Serverless and Aurora pgvector, and see why average recall hides your smallest customers.

Sr Solutions Architect
Say you run a support assistant for a product with a few hundred customers. Every question is searched only against the asking customer's documents. Your biggest customer has 18,000 documents in the index, and your smallest has 40. Same code, same index, same embedding model. Does the small customer get results as complete as the big one, and as fast?
I built the same filtered search on four AWS stores to find out, with Stack Overflow tags in place of customers. The overall averages hid two problems. Grouping results by how many rows each filter matches showed both. A second build on fresh resources, with this guide's code, showed them again, and each has a fix.
This guide shows how to run the same check on your data. The code and my request logs from both runs are in a  public repo , so you can compare your numbers with mine.


What you will build and what it found

  • What you build: one vector index per store with a filterable attribute, the same filtered top-10 query for DynamoDB, Amazon S3 Vectors, Amazon OpenSearch Serverless and Aurora pgvector, and a test that scores each answer against an exact NumPy search and groups the scores by filter width.
  • What the test caught on 100,000 Spanish Stack Overflow chunks, each query filtered by its own tag:
Share of rows matching the filter
Aurora pgvector
DynamoDB
OpenSearch Serverless
S3 Vectors
under 0.1% (85 queries)
1.000 recall, 0.8 ms
0.299 recall, 9.7 ms
1.000, 24.5 ms
0.984, 62.4 ms
5% or more (575 queries, 5 tags)
1.000, 67.6 ms
0.996, 25.7 ms
0.999, 33.8 ms
0.956, 62.4 ms
Mean recall@10 against exact search, p50 latency seen by the client.
  • How to recover recall and cut latency:
  • DynamoDB (second build): making the tag the index's  HASH  partition key, instead of an inline filter, raised recall on the narrowest filters from 0.317 to 1.000.
  • Aurora (second build): with a  javascript  partial HNSW index already in place, four planner settings (Step 7) cut the broadest bucket from 68.8 to 2.5 ms p50. Recall there fell from 1.000 to 0.971; narrow filters stayed exact.

  • Use it on your data: count the rows behind each filter value before you test, then report recall and latency for your narrowest and broadest values next to the average. My second corpus, Chilean law, filled only the two broad buckets: DynamoDB recall stayed at 0.999 or higher, and Aurora p50 rose from 1.8 to 4.8 ms.

Background: vector search, recall and the four stores

Vector search. An embedding model turns text into a vector, 1,024 numbers here. Texts with similar meaning land close together. Comparing a question with every vector is exact but slow. So stores build an approximate index, such as pgvector's HNSW graph, that visits only part of the data. It is fast, and it sometimes misses a true nearest neighbor.
Recall@10. The share of the exact top 10 that the store returned. If only 1 to 9 rows match, divide by that count; skip queries with zero matches. Order does not matter. A recall of 0.9 means 9 of 10 came back, on average. I report it next to latency because a faster search can miss more neighbors.

Filtered search. Real queries usually come with a condition: this customer, this tag. The store has to return the 10 nearest vectors among the rows that pass. It can do that two ways:
  • Search first, then drop rows that fail the filter. A rare value can leave only one or two results.
  • Collect every matching row first, then rank them. Complete, but the work grows with the number of matches.

An illustration, not data: blue dots pass the filter, the star is the question. The first build's filtered Aurora plans used the second strategy.
Each store handles this its own way, which is why the test groups results by filter width.
The four stores. Each one adds vector search to a service many teams already run:
Store
What it is
Available since
DynamoDB vector search
A vector index on a DynamoDB table, queried with  SearchVectors 
 August 2026 
Amazon S3 Vectors
Vector buckets and indexes inside S3, billed for storage, uploads and queries
 GA December 2025 
OpenSearch Serverless (next generation)
k-NN search on a  knn_vector  field in a serverless collection
 May 2026 
Aurora PostgreSQL with pgvector
The pgvector extension: a  vector  column type and HNSW indexes, queried with SQL
pgvector 0.8 on Aurora since
DynamoDB and S3 Vectors have no capacity to size. OpenSearch Serverless and Aurora Serverless v2 scale capacity units up and down and bill for them while awake, so delete them when you finish (Step 8).

What you need


  • An AWS account and a region with all four services. I used us-east-1. The repo's  infra/  folder is Terraform for the VPC, an EC2 runner, S3 Vectors, OpenSearch Serverless and Aurora Serverless v2. DynamoDB vector tables are created from Python, because Terraform could not create the vector index when I built this.
  • Python with boto3 1.43.109, numpy, opensearch-py 3.2.0, psycopg 3.3.6 and the  pgvector  package. Those are the versions I ran;  runner/uv.lock  pins them all.
  • Embeddings for your documents and your test questions, normalized to unit length, plus one filter value per document. I used Cohere Embed v4 on Amazon Bedrock at 1,024 dimensions, embedded everything once and loaded the same vectors into every store.
  • Network access to the DynamoDB search hostname.  SearchVectors  uses its own hostname,  search-dynamodb.us-east-1.amazonaws.com , or the  account-based   <account-id>.search-ddb.us-east-1.amazonaws.com . With only the main DynamoDB hostname on an egress allowlist, writes work and searches fail ( DynamoDB docs ). After the runs, the search addresses I resolved fell inside the  com.amazonaws.us-east-1.dynamodb  prefix list, so the gateway endpoint should cover them. Check both hostnames against your region's prefix list.
The code below assumes three arrays for the documents and two lists for the questions:
ids # one string per chunk, e.g. "so-48213-2"
attrs # numpy array of filter values, e.g. "javascript"
vecs # float32 array, shape (n, 1024), each row unit length

query_vecs, query_tags # one vector and one filter value per test question
Set the store names from  terraform output  in  infra/ :  bucket  from  vector_bucket ,  host  from  aoss_endpoint  (host part only), and  aurora_host  and  aurora_secret_arn  from the outputs with those names. Then  table = "fv-vec-so-cohere"  and  s3v_index = aoss_index = "so-cohere" .
My data: 100,000 chunks of Spanish Stack Overflow answers (CC BY-SA, April 2024 dump), filtered by the first tag of the answer's question, with 1,000 question titles as queries, each filtered by its own tag. The second corpus is 8,851 chunks of Chilean law from Ley Chile, filtered by which of 11 texts a chunk comes from, with 1,000 questions generated by Claude Haiku 5.5.

Step 1: Count how many rows each filter value matches

Do this before you create any index. The number of rows behind a filter value decides how much work a filtered search has to do, and it was the variable that split my results:
import collections

rows_per_value = collections.Counter(attrs)
matching = [rows_per_value[tag] for tag in query_tags] # one count per test query

def bucket_of(n, total=len(attrs)):
share = n / total
return "<0.1%" if share < 0.001 else "0.1-1%" if share < 0.01 else "1-5%" if share < 0.05 else ">=5%"

print(collections.Counter(bucket_of(n) for n in matching))
My Stack Overflow corpus had 759 tags, from  javascript  with 18,064 chunks down to tags with a single chunk, and the 1,000 test queries landed in all four buckets, 85 in the narrowest. Ley Chile's narrowest filter matched 2.9% of its chunks, so it filled only two buckets. If your test queries miss a bucket your users will hit, add queries for it. In the support assistant, the narrowest bucket is your smallest customers.


Step 2: Build an exact answer key

Recall needs a right answer to compare against. With 100,000 vectors of 1,024 floats, brute force fits in memory and takes seconds. From  runner/fv/vec.py :
import numpy as np

def exact_topk(q, base, k, allowed=None):
"""Brute-force cosine top-k; q and base rows are unit-length."""
scores = base @ q
k = min(k, len(scores))
if allowed is not None: # filtered truth: rows that fail the filter can't win
scores = np.where(allowed, scores, -np.inf)
k = min(k, int(allowed.sum()))
if k == 0:
return np.array([], dtype=np.int64)
idx = np.argpartition(-scores, k - 1)[:k]
return idx[np.argsort(-scores[idx])]

def recall_at_k(found, truth, k):
want = truth[:k]
if not want:
return float("nan")
return len(set(found[:k]) & set(want)) / len(want)

truth_plain = [[ids[i] for i in exact_topk(q, vecs, 10)] for q in query_vecs]
truth_filter = [[ids[i] for i in exact_topk(q, vecs, 10, attrs == tag)]
for q, tag in zip(query_vecs, query_tags)]
This measures how close each store gets to exact search over the same vectors. Answer quality needs its own evaluation.

Step 3: Create the index and load the vectors

Each store needs the filter attribute declared, or stored in a way it can filter on. Below is the part that matters for filtering. The full loaders, with batching, retries and the wait until every vector is searchable, are in  runner/fv/stores/ . From  runner/ ,  uv run fv load --store <name> --corpus so --model cohere  runs them for the CLI benchmark (its Aurora table is  so_cohere_chunks ). For the snippets below, use the setup in  article/verify/guide_check.py .
DynamoDB. The vector index lives on an on-demand table. Declare the filter attribute in  AttributeDefinitions  and as an  INLINE_FILTER  in the search schema:
import boto3

ddb = boto3.client("dynamodb", region_name="us-east-1")

ddb.create_table(
TableName=table, BillingMode="PAY_PER_REQUEST",
AttributeDefinitions=[{"AttributeName": "id", "AttributeType": "S"},
{"AttributeName": "attr", "AttributeType": "S"}],
KeySchema=[{"AttributeName": "id", "KeyType": "HASH"}],
VectorIndexes=[{
"IndexName": "vec", "VectorAttribute": {"AttributeName": "v"},
"Dimensions": 1024, "DistanceFunction": "COSINE",
"Projection": {"ProjectionType": "ALL"},
"SearchSchema": [{"AttributeName": "attr", "SearchSchemaElementType": "INLINE_FILTER"}],
}],
)
To load:
  • Wait for the  table_exists  waiter.
  • Write  id  and  attr  as strings and  v  as a list of numbers ( {"N": repr(float(x))} ).
  • Send up to 25 items per  BatchWriteItem  call, including the last partial batch. Retry  UnprocessedItems  with backoff from 50 ms up to 2 s.
  • Poll  describe_table  every 30 s until the index is  ACTIVE  and not  Backfilling .
Even then, the first searches can fail with  ValidationException  for a short while, so retry them before timing. One sequential loader took about 14.5 minutes for 100,000 items; use parallel threads if that is too slow.
S3 Vectors. Terraform creates the vector bucket and index ( float32 , 1,024 dimensions,  cosine ). Metadata keys are filterable unless you list them as non-filterable, so  attr  needs no declaration.  PutVectors  takes up to 500 vectors per call:
s3v = boto3.client("s3vectors", region_name="us-east-1")

for i in range(0, len(ids), 500):
s3v.put_vectors(vectorBucketName=bucket, indexName=s3v_index, vectors=[
{"key": id_, "data": {"float32": v.tolist()}, "metadata": {"attr": str(attr)}}
for id_, attr, v in zip(ids[i:i + 500], attrs[i:i + 500], vecs[i:i + 500])])
OpenSearch Serverless. Terraform creates a  VECTORSEARCH  collection (next generation) with its encryption, network and data access policies. Map  attr  as a  keyword  so a  term  filter can match it. I set  compression_level  to  1x , so OpenSearch searches full-precision vectors like the other three:
from opensearchpy import AWSV4SignerAuth, OpenSearch, RequestsHttpConnection

auth = AWSV4SignerAuth(boto3.Session().get_credentials(), "us-east-1", "aoss")
os_client = OpenSearch(hosts=[{"host": host, "port": 443}], http_auth=auth,
use_ssl=True, connection_class=RequestsHttpConnection, timeout=120)

os_client.indices.create(index=aoss_index, body={
"settings": {"index": {"knn": True}},
"mappings": {"properties": {
"v": {"type": "knn_vector", "dimension": 1024,
"space_type": "cosinesimil", "compression_level": "1x"},
"attr": {"type": "keyword"}}}})
Load with  opensearchpy.helpers.bulk  ( chunk_size=200 ,  max_retries=5 ), one action per chunk with  _index=aoss_index ,  _id=id_  and  _source={"v": v.tolist(), "attr": str(attr)} . Then poll  os_client.count(index=aoss_index)["count"]  until it reaches  len(ids) . S3 Vectors loaded in about 3.5 minutes, OpenSearch in about 5, including that wait.
Aurora pgvector. A table with a  vector  column, loaded with binary  COPY , with indexes built after the load. Register the vector type and pass a  Vector , or psycopg sends a Python list as a Postgres array:
import json
import psycopg
from pgvector import Vector
from pgvector.psycopg import register_vector

login = json.loads(boto3.client("secretsmanager", region_name="us-east-1")
.get_secret_value(SecretId=aurora_secret_arn)["SecretString"])
user, password = login["username"], login["password"]

conn = psycopg.connect(host=aurora_host, dbname="postgres", user=user, password=password,
sslmode="require", connect_timeout=30, autocommit=True)
conn.execute("CREATE EXTENSION IF NOT EXISTS vector")
conn.execute("ALTER EXTENSION vector UPDATE") # iterative scans need 0.8 or later; I ran 0.8.2
register_vector(conn)
conn.execute("CREATE TABLE so_chunks (id text PRIMARY KEY, attr text, v vector(1024))")

with conn.cursor() as cur, cur.copy("COPY so_chunks (id, attr, v) FROM STDIN WITH (FORMAT BINARY)") as cp:
cp.set_types(["text", "text", "vector"])
for id_, attr, v in zip(ids, attrs, vecs):
cp.write_row((id_, str(attr), Vector(v)))

conn.execute("SET maintenance_work_mem = '1GB'")
conn.execute("CREATE INDEX ON so_chunks USING hnsw (v vector_cosine_ops) WITH (m = 16, ef_construction = 64)")
conn.execute("CREATE INDEX ON so_chunks (attr)")
conn.execute("ANALYZE so_chunks")
From creating the table to  ANALYZE , it took about 2 minutes for 100,000 rows.

Step 4: Write the filtered query

The filter is an equality on  attr . Each function returns the ids of the top 10:
def query_ddb(vec, tag):
r = ddb.search_vectors(
TableName=table, IndexName="vec", TopK=10,
SearchVector=[{"N": repr(float(x))} for x in vec],
SearchConditionExpression="#a = :a",
ExpressionAttributeNames={"#a": "attr"},
ExpressionAttributeValues={":a": {"S": tag}},
ProjectionExpression="id")
return [h["Item"]["id"]["S"] for h in r["SearchResults"]]

def query_s3v(vec, tag):
r = s3v.query_vectors(
vectorBucketName=bucket, indexName=s3v_index, topK=10,
queryVector={"float32": [float(x) for x in vec]},
filter={"attr": {"$eq": tag}}, queryMode="ENHANCED") # filter before the search
return [v["key"] for v in r["vectors"]]

def query_aoss(vec, tag):
r = os_client.search(index=aoss_index, body={
"size": 10, "_source": False,
"query": {"knn": {"v": {"vector": [float(x) for x in vec], "k": 10,
"filter": {"term": {"attr": tag}}}}}})
return [h["_id"] for h in r["hits"]["hits"]]

conn.execute("SET hnsw.iterative_scan = relaxed_order") # keep scanning, within pgvector's scan limits, until 10 rows pass

def query_aurora(vec, tag):
return [row[0] for row in conn.execute(
"SELECT id FROM so_chunks WHERE attr = %s ORDER BY v <=> %s LIMIT 10",
(tag, Vector(vec))).fetchall()]
The snippets are collected in  article/verify/guide_check.py , which produced the second-build baseline and  HASH  test. Before timing, call each function once with a common filter value. Check that it returns 10 ids, all with that value in  attrs .
Details to get right:
  • S3 Vectors: a filter or  returnMetadata=True  also needs  s3vectors:GetVectors  in the IAM policy, or the query fails with a 403.
  • Aurora:  iterative index scans  are off by default. With  relaxed_order , results can come back slightly out of order, which does not affect recall@10.
  • DynamoDB:  TopK  is capped at 100. Since  November 20, 2026 , the  operator reference  lists  <>  and  IN  on any type, range operators on numbers,  AND ,  OR ,  NOT  and existence checks. I tested  =  only. For  BETWEEN , declare a Number inline filter and use the same inclusive bounds in the answer key and the Step 1 count. A  HASH  element still accepts only  = .

Step 5: Time each request and keep every row

Run one query at a time from a machine close to the stores. I used an EC2  m7g.2xlarge  in the lab VPC, with PrivateLink to S3 Vectors and OpenSearch. With one sequential client I measured latency per request; throughput needs its own test. Send 20 warm-up queries per store, then make 3 passes and write one CSV row per request. Simplified from  runner/fv/harness.py :
import csv, time

stores = {"ddb": query_ddb, "s3v": query_s3v, "aoss": query_aoss, "aurora": query_aurora}

with open("requests.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(["store", "rep", "qi", "latency_ms", "recall", "ok", "error"])
for name, query in stores.items():
for vec, tag in list(zip(query_vecs, query_tags))[:20]:
try:
query(vec, tag) # warm-up, not recorded
except Exception as e:
print(name, "warm-up failed:", e)
for rep in range(1, 4):
for qi, (vec, tag) in enumerate(zip(query_vecs, query_tags)):
t0 = time.perf_counter()
try:
got = query(vec, tag)
ms = (time.perf_counter() - t0) * 1000
writer.writerow([name, rep, qi, ms, recall_at_k(got, truth_filter[qi], 10), True, ""])
except Exception as e: # recorded, never silently fast
ms = (time.perf_counter() - t0) * 1000
writer.writerow([name, rep, qi, ms, "", False, f"{type(e).__name__}: {e}"])
Then run the loop without the filter, against  truth_plain , into a second CSV. That shows what the filter costs. Use the DynamoDB  INLINE_FILTER  table without its condition fields. Drop  filter  and  queryMode  from S3 Vectors,  filter  from OpenSearch, and  WHERE attr = %s  from Aurora, passing  (Vector(vec),)  as the parameters.
My first build logged 72,000 timed requests across two corpora and three query cases, with zero errors. I later found the filter-width effect in those same CSVs, without running another test.

Step 6: Group the results by filter width

Start with the averages from the first build on Stack Overflow:

Store
No filter: p50, recall
With filter: p50, recall
Aurora pgvector
1.31 ms, 0.927
46.14 ms, 1.000
DynamoDB
12.72 ms, 0.996
24.18 ms, 0.899
OpenSearch Serverless
29.95 ms, 0.961
30.89 ms, 0.9996
S3 Vectors
62.27 ms, 0.961
62.39 ms, 0.958
Mean recall@10 over 1,000 queries. p50 measured at the client, including the round trip.
Without a filter, Aurora's lower recall comes from pgvector's default  hnsw.ef_search  of 40. At 200 it reached 0.986 at 3.20 ms p50. At 100 the p95 jumped to 110 ms, which I did not investigate. DynamoDB's 0.996 meets the " 99%+ recall " in its launch announcement.
To see how DynamoDB recall and Aurora latency vary with filter width, join the Step 1 counts to the request rows:
import collections, csv, math, statistics

groups = collections.defaultdict(lambda: ([], []))
for r in csv.DictReader(open("requests.csv")):
if r["ok"] == "True" and not math.isnan(float(r["recall"])): # skip queries with no possible neighbors
recalls, latencies = groups[(r["store"], bucket_of(matching[int(r["qi"])]))]
recalls.append(float(r["recall"]))
latencies.append(float(r["latency_ms"]))

for (store, b), (recalls, latencies) in sorted(groups.items()):
print(store, b, round(statistics.mean(recalls), 3), round(statistics.median(latencies), 1))
Also count failed rows per bucket, since keeping only successes can make a store look faster. I recorded none.
Plotted per tag, with one dot per store per tag, my results looked like this:

Stack Overflow, 116 tags. For the highlighted store, dot size is the number of queries with that tag (capped). The other three stores are small grey dots.
Two tags show the extremes:
  •  asp.net  (250 rows, 3 requests): DynamoDB mean recall 0.867, Aurora p50 2.1 ms.
  •  javascript  (18,064 rows, 468 requests): 0.999 and 81.0 ms.
What each store did:
  • DynamoDB lost neighbors on narrow filters. On tags under 0.1% of the rows, mean recall was 0.299. Counting only the 62 queries whose tag had at least 10 rows, it was 0.323. Results also varied between passes: in the next bucket, one  asp.net  query scored 0.9, 0.7 and 1.0. AWS says DynamoDB " skips vectors that don't match your filter as it searches the index ", and the search is approximate. I don't know why rare filters lose neighbors, but the fix below worked.
  • Aurora slowed down on broad filters. Recall stayed at 1.000 while p50 went from 0.8 to 67.6 ms. Raising  ef_search  barely moved filtered p50: 46.14, 46.29 and 46.33 ms p50 at 40, 100 and 200. Step 7 shows why.
  • OpenSearch and S3 Vectors changed least. OpenSearch kept recall at about 1.0 while p50 rose from 24.5 to 33.8 ms. S3 Vectors stayed between 62.3 and 62.6 ms p50 in every bucket, with mean recall between 0.950 and 0.984.

The DynamoDB fix: make the filter the partition key

A  HASH  element in the search schema makes the attribute a  vector index partition key . Each search then covers only the vectors with one value. In a new table definition, replace  INLINE_FILTER  with  HASH . The query stays the same:
"SearchSchema": [{"AttributeName": "attr", "SearchSchemaElementType": "HASH"}],
To measure the difference, load the same 100,000 vectors into two tables, one with  INLINE_FILTER  and one with  HASH , and run the same 3 passes of 1,000 filtered queries on both. The same Step 4  SearchConditionExpression  serves both; only the table name changes ( query_ddb_on(name)  in  guide_check.py ):
Share of rows matching the filter
 INLINE_FILTER 
 HASH 
under 0.1% (85 queries)
0.317 recall, 9.6 ms
1.000 recall, 13.8 ms
0.1% to 1% (125 queries)
0.802, 19.8 ms
1.000, 10.4 ms
1% to 5% (215 queries)
0.942, 29.3 ms
0.996, 17.4 ms
5% or more (575 queries)
0.997, 33.4 ms
0.998, 23.1 ms
all queries
0.903, 31.5 ms
0.998, 20.8 ms
Second build. Mean recall@10, p50 latency, 3,000 requests per table, zero errors.
The partition key comes with  rules :
  • Every search needs exactly one top-level  =  condition on it, joined to other conditions with  AND . One call cannot search all tags or  OR  two tags.
  • An item written without the attribute is left out of the index, with no error.
  • It is not an access-control boundary: any caller with search permission can query any value, so enforce access separately ( filtering ).
  • AWS cautions against both very few and very many values. My 759 tags, many with a single row, still scored 1.000 on the narrowest bucket.
In the support assistant, the customer id is the natural partition key.
On the second build, the other stores showed similar latency by bucket. DynamoDB with the inline filter had the same recall pattern, with overall p50 at 31.5 ms against 24.2 ms on the first build.

Step 7: When latency jumps, read the plan

For Aurora,  EXPLAIN (ANALYZE, BUFFERS)  shows what the filter does. Run it on a narrow value, a broad value, and once without a filter:
plan = conn.execute(
"EXPLAIN (ANALYZE, BUFFERS) SELECT id FROM so_chunks WHERE attr = %s ORDER BY v <=> %s LIMIT 10",
("javascript", Vector(query_vecs[0]))).fetchall()
print("\n".join(row[0] for row in plan))
What I saw:
  • No filter: Postgres walked the HNSW index, 0.7 to 1.9 ms on my first three queries.
  • With a filter: all three first-build plans used the B-tree index on  attr  ( Bitmap Index Scan ), never the HNSW index. It fetched every matching row, computed each distance and kept the top 10 with a top-N heapsort. That exact scan is why  ef_search  changed nothing, and all 3,000 filtered requests had 1.000 recall.
  • Cost grows with rows:  asp.net  read 250 rows, 1,272 buffer hits, 1.5 ms.  javascript  read 18,064 rows, 79,245 hits, 83.8 ms, of which 81.4 ms was the bitmap heap scan. My untested guess: each 4 KB vector is stored out of line, so every row costs extra reads.
In your own plans, an  Index Scan  on the HNSW index means approximate search. A  Bitmap Index Scan  on  attr  followed by a top-N sort means an exact scan of every matching row. My first-build  javascript  plan (table  so_cohere_chunks ) touched 977 heap blocks, used 25 kB for the sort and ran in 83.829 ms. Full plans and node timings are in  results/2026-10-09/aurora-explain.json .
This plan is fast for narrow filters and slow for broad ones. To fix the broad case, take the most common tag,  javascript , and time its 468 requests (156 queries, 3 passes) after each change:

In the fourth bar,  EXPLAIN  showed the fast plan, but my timed loop stayed slow. I suspect plan caching:
  • A generic plan cannot know the tag is  'javascript' , so it cannot use the partial index.
I did not capture the plan inside the loop, but forcing custom plans made it fast. This is what I ran:
conn.execute("SET maintenance_work_mem = '1GB'")
conn.execute("CREATE INDEX so_chunks_js_hnsw ON so_chunks USING hnsw (v vector_cosine_ops) "
"WITH (m = 16, ef_construction = 64) WHERE attr = 'javascript'")
conn.execute("ANALYZE so_chunks")
conn.execute("SET enable_bitmapscan = off")
conn.execute("SET enable_seqscan = off")
conn.execute("SET plan_cache_mode = force_custom_plan") # let the planner see the literal tag
conn.execute("SET hnsw.ef_search = 100") # 0.988 recall at 1.9 ms p50
These settings apply to every query on the connection, so check the other tags too. On a fresh cluster, with the  javascript  partial index in place, I ran all 1,000 filtered queries with default settings, then with the four settings above:
Share of rows matching
Default settings
Forced settings,  ef_search  100
under 0.1%
1.000 recall, 0.9 ms
1.000, 0.9 ms
0.1% to 1%
1.000, 3.2 ms
1.000, 3.0 ms
1% to 5%
1.000, 15.8 ms
0.975, 2.7 ms
5% or more
1.000, 68.8 ms
0.971, 2.5 ms
all queries
1.000, 47.3 ms (p95 85.9 ms)
0.978, 2.5 ms (p95 7.2 ms)
  • Narrow tags stayed exact:  asp.net  still read its 250 rows through the  attr  index.
  • Broad-filter recall fell: 0.975 and 0.971 in the two broad buckets, from 0.956 ( php ) to 0.989 ( javascript ) per tag. In  EXPLAIN ,  python  (9,801 rows, no partial index) switched to the table-wide HNSW index with iterative scan.
  • Not measured: I did not time  javascript  without its partial index under these settings. Partitioning the table by tag is the other fix I would try.
To apply the settings to one query at a time, open a fresh connection with only  hnsw.iterative_scan = relaxed_order . Run each query in a transaction: first the four  SET LOCAL  statements, each with  prepare=False , then the search ( article/verify/aurora_scope.py ). On  javascript  that gave 0.988 recall at 5.9 ms p50 with  ef_search  100, and 0.957 at 5.1 ms with 40. The extra round trips may explain some of the added latency.

Step 8: Measure idle time, then clean up

A support assistant has quiet hours, so time the first search after a pause too. I did one trial per store after about 16 minutes without traffic.

Store
First result after ~16 min idle
Estimated monthly compute to stay awake
DynamoDB
87 ms
none, billed per request
S3 Vectors
89 ms
none, billed per request
Aurora Serverless v2
14.0 s (12.5 s to resume and connect)
about USD 249 at 2.84 ACU on the large bench (USD 59 at 0.67 ACU in one small-bench sample)
OpenSearch Serverless
23.2 s
USD 175.20 at 1 search OCU
One idle trial per store, including client setup, so treat the times as an order of magnitude. Costs are us-east-1 list prices for 730 hours at the capacity I measured; storage is extra for all four.
I set Aurora to auto-pause after 10 idle minutes. My OpenSearch collection group had zero minimum OCUs, so it  scales to zero  after 10 idle minutes across the group, with 10 to 30 seconds documented to wake search. Traffic every few minutes kept both awake in my setup. The table estimates 730 hours awake at the capacity I measured.
When you finish, delete the DynamoDB vector tables by name ( ddb.delete_table(TableName=...) , including the  HASH  table), then run  terraform destroy  in  infra/ . The workflow  gh workflow run infra.yml -f action=destroy  also deletes tables prefixed  fv-vec-  in the account.

How I would choose now

  • If you want SQL around the search, I would test Aurora pgvector first and run  EXPLAIN  on the broadest filter value you have. If broad filters are slow, I would try the Step 7 planner settings and accept slightly lower recall on them.
  • If traffic is spiky or rare and you want no compute floor, I would test DynamoDB. If every query supplies one value of the filter, such as a customer id, I would make it the  HASH  partition key from the start.
  • If filters come in every width and recall has to stay near 1.0, I would test OpenSearch Serverless, if the always-on cost fits.
  • For large, cold collections where about 60 ms is fine, I would test S3 Vectors, which stayed near 62 ms p50 in every bucket.
For a support assistant, I would count indexed chunks per customer before choosing a store, make the customer id the partition key where the store has one, and report recall and median latency for the smallest and largest customers next to the average.

Run it from the repo

The  repo  has the full version of this guide in  article/article.md . To run it:
  1. In your lab account, set up the GitHub OIDC provider. Fill  lab_account_id ,  github_sub  and  alert_email  in  infra/bootstrap/terraform.tfvars , then run  terraform init  and  terraform apply  there.
  1. Set the repository variables  AWS_ROLE_ARN  (from  gha_role_arn ) and  TF_STATE_BUCKET  (from  state_bucket ). Provision with  gh workflow run infra.yml -f action=apply ; the default action is  plan .
  1. In  runner/ , run  uv sync --frozen , then  uv run fv so-prepare --dump <dir>  on the extracted Spanish Stack Overflow dump.
  1. Run the benchmarks on the EC2 runner. From another machine that can reach the stores, add your  AWS_PROFILE  to  LAB_PROFILES  in  runner/fv/config.py , since AWS commands refuse other profiles, and export the  FV_*  store settings from  terraform output .
The core loop, from  runner/ :
uv run fv embed --corpus so --model cohere # embeddings
uv run fv truth --corpus so --model cohere # Step 2
for s in ddb s3v aoss aurora; do
uv run fv load --store $s --corpus so --model cohere # Step 3
uv run fv bench --store $s --corpus so --model cohere --case filter --reps 3 # Steps 4 and 5
uv run fv bench --store $s --corpus so --model cohere --case plain --reps 3 # unfiltered
done
To run this guide's snippets, including the  HASH  test, use the EC2 runner: from  runner/ , run  FV_DATA_DIR="$PWD/data" uv run python ../article/verify/guide_check.py load , then the same with  bench . It drops and recreates  so_chunks  and reuses cached truth by file name, so use a lab database and a fresh  FV_DATA_DIR . Its output is in  results/2026-11-24/ . To check the first build's tables without AWS, run  python3 article/analysis.py ; it needs only the standard library and the committed CSVs.

Limits

  • 100,000 vectors at most. Bigger indexes can change every result here.
  • One sequential client: latency per request, no throughput numbers.
  • One region, one embedding model, equality filters only, OpenSearch at 1x compression only. The first build ran on October 8 and 9, 2026, and the second on November 24.
  • The broadest bucket holds 575 queries but only 5 tags, and the Aurora partial index was tested on one tag.
  • OpenSearch Serverless had GPU acceleration for index builds on, and I could not turn it off for the collection. GPU indexing is billed separately and not in the cost figures.
  • The DynamoDB gateway-endpoint routing is inferred from DNS after the runs, not from flow logs.
  • Versions: Aurora PostgreSQL 17.11 with pgvector 0.8.2, OpenSearch Serverless next generation. Prices are list prices from the AWS Price List API on October 8, 2026, in us-east-1.

About me

I'm Andrés, from Arequipa, Peru. I'm a Senior Solutions Architect in Enterprise Managed Services at phData, working mostly with AWS, and I started out as a Data Engineer. I'm an AWS Community Builder and hold the AWS Golden Jacket. Away from the keyboard, I'm passionate about skiing.
Let's connect on  LinkedIn , or find the code for this article on  GitHub .
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article