---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://mixpeek.com/.well-known/search?q={query}"
  method: GET
  documentation: "https://mixpeek.com/llms.txt"
---

Vector Search

8 min read

Updated 2026-11-08

# Why Does My Search Get Slower as the Collection Grows, Even With a Narrow Filter?

A filter that keeps 500 rows should cost about the same in a 1-million-row collection as in a 10-million-row one. When it does not, a count, a sort or a keyword step is walking an index over every row of the field. How to find the slow step, why planners choose it, and the fixes in PostgreSQL, Elasticsearch and vector stores, with our own before and after numbers at 8.17 million rows.

![Ethan Steininger](/people/ethan.webp)

By [Ethan Steininger](/blog/authors/ethan), Founder & CEO, Mixpeek

Filtered Search

Facets

Query Planning

Performance

Vector Database

MVS

[Filtered counts and sorted pages that scale with the matches. Try it as you read.See MVS →](/mvs)

[One-click templatesStart from a templateEach template deploys a working search app on your own files.Browse templates](/templates)

## Why does my search get slower as the collection grows, even with a narrow filter?

  
  
Some step of the query is still reading the whole field instead of the rows the filter kept. A filter that matches 500 rows should cost about the same in a collection of 1 million rows as in one of 10 million. When the time grows with the collection while the number of matches stays flat, the usual cause is a facet count, a sort or a keyword clause that walks an index built over every row of a field and checks each entry against the filter. The fix is to start from the filter's matches whenever they are the smaller set, and count, sort and test words over those rows only.  
  

## Which parts of a query grow with the collection?

  
  

Step

Slow path: cost grows with the collection

Fast path: cost grows with the matches

Facet count (values and their counts)

Visit every value's list of rows for the field and intersect each with the filter

Read each match's value, or, for a field with few values, look each value up among the matches

Sorted page

Walk the sort field's index in order until enough rows pass the filter

Read the sort key of each match, sort those, return the page

Keyword search inside a filter

Build the set of every row containing the words, then intersect it with the filter

Test the words on each match

Total count on every page

Resolve the whole filter again for each page

Resolve it once and reuse it

  
  
The slow path is the right choice when the filter is broad. If a filter keeps 60% of a collection, walking the index once is cheaper than reading millions of matches one at a time. So a query planner has to estimate how many rows the filter keeps and pick a path, and the slowdown appears when that estimate is missing or wrong.  
  

## Why does the database pick the slow path?

  
  
*   **The selective clause is hidden.** APIs often wrap the caller's filter inside an AND group together
with a tenant or permission scope. A planner that reads only the top-level clauses never sees the narrow one and drives from a broad clause instead.*   **Sorting with a limit.** For `ORDER BY created_at LIMIT 50` a planner may walk the `created_at`
index and filter as it goes. That is fast when most rows pass and slow when few do, because it may walk most of the index to find 50. In PostgreSQL's \[`EXPLAIN ANALYZE`\](https://www.postgresql.org/docs/current/using-explain.html) this shows as an index scan on the sort column with a Filter line and a large "Rows Removed by Filter" count.*   **Facets on fields with many values.** Counting a field such as `asset_id` with hundreds of thousands
of distinct values by visiting each value's list is expensive however few rows matched. Elasticsearch's terms aggregation exposes this choice as \[`execution_hint`\](https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-terms-aggregation): the default global ordinals path suits broad queries, and Elastic's documentation says `map`, which buckets the matching documents' own values, should only be considered when very few documents match.*   **Long lists of values.** A clause like "folder is one of these 300 IDs" can pass a planner's limit for
using the index and fall back to a scan.  
  

## How do I find the slow step?

  
  
1\. Time the query with each part removed in turn: no facet, no sort, no keyword clause. 2. Run the same filter against collections of different sizes. If the time grows with the collection while the match count stays the same, one step is walking the field. 3. Read the plan: `EXPLAIN ANALYZE` in PostgreSQL, or `"profile": true` in Elasticsearch and OpenSearch ([search profile API](https://www.elastic.co/docs/reference/elasticsearch/rest-apis/search-profile)). 4. Move the narrow clause to the top level of the filter and time it again. If that fixes it, the planner could not see the clause.  
  

## How do I fix it?

  
  
*   **Let the planner see the narrow clause.** Flatten nested AND groups where you control the query, and
keep table statistics current.*   **Give the sort an index that starts with the filter.** In PostgreSQL a composite index on
`(tenant_id, created_at)` returns one tenant's rows already in date order, so the sort reads only matching rows.*   **Count facets from the matches when the filter is narrow.** In Elasticsearch that is
`execution_hint: map` on the terms aggregation for those queries.*   **Precompute what does not need to be fresh.** Counts shown as "about 12,000" can come from a cache or a
nightly job.*   **Check the answers, too.** A faster path has to return the same rows, the same counts and the same
order. Compare a sample of queries before and after.  
  

## What did this look like in our own vector store?

  
  
MVS, the vector store behind Mixpeek, had this problem on filtered facet counts, sorted pages and keyword search inside a filter: each walked the field's index, so they slowed down as a collection grew even when the filter matched a few hundred rows. It now reads the filter's matches first, including clauses nested inside AND groups, and counts, sorts and tests words over those rows when a cost rule says that is cheaper. Filters that keep most of a collection still take the old path.  
  

Benchmark at 8.17 million rows (median)

Before

After

Filtered distinct count

8.9 s

22 ms

Sorted page of 50

456 ms

13 ms

Keyword search scoped to 96 folders

7.5 s

266 ms

  
  
Every answer matched the old path exactly. The change is in the [changelog](/changelog) for 7 November 2026. [MVS](/mvs) keeps vectors and payloads on object storage, S3 or GCS, and serves filtered vector search, keyword search and facets from the same index.  
  
Related: [why vector search returns fewer results when you add a filter](/guides/why-vector-search-returns-fewer-results-with-filter) and [filtered vector search](/guides/filtered-vector-search-pre-post-in-place).  
  

## Frequently Asked Questions

  
  

### Why is my facet count slow when the filter matches only a few rows?

  
  
The count is probably walking every value of the field and checking each against the filter, which costs the same however few rows matched. Count from the matches instead, or in Elasticsearch set `execution_hint` to `map` for narrow queries.  
  

### Why is ORDER BY with LIMIT slow on a filtered query?

  
  
The planner is likely walking the sort column's index and discarding rows that fail the filter until it has enough. With a narrow filter that means reading most of the index. An index that starts with the filter column and ends with the sort column fixes it in PostgreSQL.  
  

### How do I know whether my search will slow down as data grows?

  
  
Run the same filtered query on a copy of your data at two or three sizes. If the time rises with the collection while the number of matches stays flat, it will keep rising.  
  

### Does the faster path change the results?

  
  
It should not, and you should check. Compare rows, counts and order for a sample of real queries on both paths before you switch. In our benchmark every answer matched.

## Filtered counts and sorted pages that scale with the matches

MVS, Mixpeek's vector store on object storage, reads a filter's matches first when that costs less, so facets, sorted pages and keyword search stay in milliseconds as a collection grows.

[See MVS](/mvs)[Read the changelog](/changelog)

[Explore MVS](/mvs)[See pricing](/pricing)

## Related guides

[

Vector Search

### Why Does My Search Slow Down When I Combine Keyword and Vector Search?

A hybrid query runs a keyword search and a vector search and then merges them, so it costs more than either one. When it costs far more, the searches are usually running one after another, each fetching a deep candidate list, with a filter checked hit by hit. How to find which of the three it is, the fixes in Elasticsearch, OpenSearch and vector stores, and our own before and after numbers at 2.65 million rows.

Read guide →](/guides/why-does-search-slow-down-when-combining-keyword-and-vector-search)[

Data Infrastructure

### How Much Does a Vector Database Cost? A 2026 Pricing Comparison

A vendor-neutral breakdown of vector database pricing in 2026: what drives cost (bytes, RAM vs object storage, replication), how Pinecone, Weaviate, Qdrant, Zilliz, turbopuffer, and Mixpeek MVS price, a worked cost-estimation formula, and which architecture is cheapest for each workload shape.

Read guide →](/guides/vector-database-cost-comparison)[

Retrieval

### Query Planning for Multimodal Retrieval: Stage Order, Filter Pushdown, and Candidate Budgets

Why the same five retrieval stages can differ by two orders of magnitude in cost depending only on their order and their candidate budgets. Covers pre-filter versus post-filter and why naive filtering destroys recall on a graph index, how to measure selectivity when your vector store keeps no statistics, how to size the reranker budget from a recall curve instead of a guess, deduplicating before the expensive stage, and what changes when the rows are video scenes rather than text chunks.

Read guide →](/guides/query-planning-multimodal-retrieval)