What does Filter mean in a PostgreSQL EXPLAIN plan?

Filter means PostgreSQL read those rows and then threw them away. Index Cond means the condition navigated the index, deciding which entries to read at all. The difference is work avoided versus work wasted, and Rows Removed by Filter tells you which one you got.

Key facts

| Fact | Value | |---|---| | Index Cond | The predicate was used to descend and scan the index — rows not matching are never read (docs) | | Filter | The predicate is applied after the row is read; rejects are counted as Rows Removed by Filter (docs) | | The diagnostic number | Rows Removed by Filter, printed only when ANALYZE is used and only when rows were actually discarded (docs) | | Recheck Cond | A third thing entirely — bitmap scans only, printed on every one of them (docs) | | Join equivalent | Join Filter / Rows Removed by Join Filter on a join node (docs) | | BUFFERS in PG18 | Enabled by default when ANALYZE is used (docs) | | Fleet data | Across 50 monitored instances, 86% are not capturing plans automatically, so the slow run leaves no plan to read |

Why this happens

Here is the whole distinction in one plan. The fixture: a 5,000,000-row orders table (521 MB), one B-tree on (merchant_id, created_at_utc), PostgreSQL 18.4, parallelism and JIT disabled, cache warm.

EXPLAIN (ANALYZE, BUFFERS)
SELECT order_id, created_at_utc, order_total_amount_pence
FROM orders
WHERE merchant_id = 42 AND status = 'refunded'
ORDER BY created_at_utc DESC
LIMIT 20;
 Limit  (cost=0.43..943.45 rows=20 width=24) (actual time=0.063..0.917 rows=20.00 loops=1)
   Buffers: shared hit=1021
   ->  Index Scan Backward using orders_merchant_created_idx on orders  (actual time=0.062..0.914 rows=20.00 loops=1)
         Index Cond: (merchant_id = 42)          <-- navigated the index
         Filter: (status = 'refunded'::text)     <-- read the row, then judged it
         Rows Removed by Filter: 998             <-- the bill
         Buffers: shared hit=1021
 Execution Time: 0.936 ms

merchant_id = 42 is in Index Cond, so PostgreSQL descended straight to that merchant's entries and never looked at the other 199 merchants. status = 'refunded' is in Filter, so for every entry the index handed back, PostgreSQL fetched the heap row, examined status, and discarded it if it did not match.

The plan returned 20 rows in under a millisecond. But it touched 1,021 buffers to do it, because it read 1,018 rows and kept 20. Rows Removed by Filter: 998 next to rows=20 is the signal: this index is doing less than it looks like it is. The ratio, not the absolute number, is what matters — 50 rows read per row returned.

The same predicate lands in Filter rather than Index Cond for one of three reasons.

1. The column is not in the index, or not in a usable prefix position. status is simply absent from orders_merchant_created_idx. A B-tree can only navigate on a leading run of its columns; a condition on a later column can be applied while scanning, but not to skip ahead. If you are unsure which columns of a composite index your query can navigate on, how a B-tree index works is the prerequisite.

2. The expression does not match the index expression. This one bites hardest, because the column is indexed. created_at_utc is the second column of the index in use, and this predicate still lands in Filter:

   ->  Index Scan Backward using orders_merchant_created_idx on orders (actual time=14.311..14.328 rows=20.00 loops=1)
         Index Cond: (merchant_id = 42)
         Filter: ((created_at_utc)::date = '2025-02-11'::date)
         Rows Removed by Filter: 19230
         Buffers: shared hit=19261

19,230 rows thrown away for 20 returned, 19,261 buffers. The index stores timestamptz values; the predicate asks about date values, so it cannot navigate. A function call (lower(customer_email_address)) behaves identically: on the same fixture, 24,999 rows removed and 25,015 buffers to return one row. An implicit collation difference does the same thing, less visibly.

3. The operator is not supported by that index's operator class. A B-tree operator class provides <, <=, =, >=, > and nothing else (docs). A trailing-wildcard LIKE has no B-tree operator to use, so it becomes a filter:

         Index Cond: (merchant_id = 42)
         Filter: (customer_email_address ~~ '%@example.net'::text)
         Rows Removed by Filter: 57

Note the number: 57 rows removed, 80 buffers, 0.108 ms. This one is fine. A filter is only a defect when it discards a lot.

How to detect it

Run the query with ANALYZE, and read the two numbers on each node together:

EXPLAIN (ANALYZE, BUFFERS)
SELECT /* your query */;

Then work down the plan asking one question per node: how many rows did it return, and how many did it remove? Without ANALYZE you get the Filter line but no counter, because nothing has run.

Three related lines are commonly mistaken for it.

Filter on a Seq Scan is normal. A sequential scan has no index to navigate, so every predicate is a filter by definition:

   ->  Seq Scan on orders (actual time=0.226..230.080 rows=100023.00 loops=1)
         Filter: (status = 'refunded'::text)
         Rows Removed by Filter: 4899977

4.9 million rows removed looks alarming and is not, on its own, a problem — reading 5 million rows to return 100,023 may well be cheaper than 100,023 random heap fetches. Judge it on total time and on whether the predicate is selective enough to deserve an index, not on the counter.

Recheck Cond is a different mechanism. It appears only on bitmap heap scans, and on every one of them, whether or not anything was rechecked. Both lines can appear on the same node:

 Bitmap Heap Scan on orders (actual time=3.780..30.100 rows=495.00 loops=1)
   Recheck Cond: (merchant_id = 42)        <-- re-applying the INDEX condition
   Filter: (status = 'refunded'::text)     <-- a predicate no index covered
   Rows Removed by Filter: 24505
   Heap Blocks: exact=21139

Recheck Cond re-applies the index condition, and only for pages the bitmap had to degrade to page granularity; its rejects are reported separately as Rows Removed by Index Recheck, absent here because no page was lossy. Filter is a predicate the index never covered. How a bitmap heap scan works covers the exact and lossy distinction.

Join Filter is the same idea one level up. A predicate that could not become a join key is evaluated on every candidate pair:

 Hash Join (actual time=6.626..59.417 rows=2926.00 loops=1)
   Hash Cond: (o.customer_id = c.customer_id)
   Join Filter: (c.signup_at_utc < (o.created_at_utc - '400 days'::interval))
   Rows Removed by Join Filter: 22074

Hash Cond is the navigational part; Join Filter is the discarded work. Read it exactly as Index Cond versus Filter, and see join optimization when the removed count dominates.

INCLUDE columns are the genuinely confusing case. An index declared (merchant_id, created_at_utc) INCLUDE (status) stores status in its leaf entries but not in its key structure, so it cannot be navigated on (docs). The predicate therefore shows up in Filter — but on an index-only scan it is checked inside the index, with no heap access:

   ->  Index Only Scan Backward using orders_merchant_created_inc_status_idx on orders (actual time=0.100..0.210 rows=20.00 loops=1)
         Index Cond: (merchant_id = 42)
         Filter: (status = 'refunded'::text)
         Rows Removed by Filter: 1030
         Heap Fetches: 0
         Buffers: shared hit=11

1,030 rows removed — more than the first plan's 998 — and yet 11 buffers instead of 1,021, and 0.299 ms. Heap Fetches: 0 is the line that redeems the filter. Read Rows Removed by Filter together with Buffers and Heap Fetches: a filter inside a covering index is cheap in a way the counter alone does not convey.

How MyDBA shows this

A collected plan whose Index Scan carries both an Index Cond and a Filter, with the rows each one eliminated.

MyDBA collects EXPLAIN plans from real executions rather than replays, so the Rows Removed by Filter you read is the one from the moment the query was slow, with the statistics, parameters and cache state it actually had — a counter lost when someone re-runs the statement by hand the next morning against a warm cache. That matters because across 50 monitored instances, 86% have no automatic plan capture at all, and of 34 instances with some capture, 26.5% still fail the explain-coverage check; for most, the honest answer to "what was in Filter when it was slow?" is that nobody recorded it — see auto_explain slow query capture. The free plan visualizer at /tools/explain-plan-visualizer parses Rows Removed by Filter per node and needs no account.

The plan visualizer highlighting a node where Rows Removed by Filter dwarfs the rows it returned.

If you would rather have this applied to your own instance, the free PostgreSQL health check scores plan capture and index usage together.

How to fix it

1. Extend the index. Adding status between the two existing columns turns the opening example's filter into a key:

CREATE INDEX CONCURRENTLY orders_merchant_status_created_idx
  ON orders (merchant_id, status, created_at_utc);
   ->  Index Scan Backward using orders_merchant_status_created_idx on orders (actual time=0.040..0.133 rows=20.00 loops=1)
         Index Cond: ((merchant_id = 42) AND (status = 'refunded'::text))
         Buffers: shared hit=23
 Execution Time: 0.154 ms

No Filter line, no counter, 1,021 buffers down to 23 and 0.936 ms down to 0.154 ms. Put the equality column before the range column — created_at_utc still has to be last for the ORDER BY to be satisfied by the index.

2. Match the expression, or rewrite so none is needed. An index on lower(customer_email_address) moves that predicate into Index Cond — 25,015 buffers down to 5, and 0.052 ms. The created_at_utc::date case cannot be fixed that way: PostgreSQL refuses the index outright, because casting timestamptz to date depends on TimeZone and so is not immutable.

ERROR:  functions in index expression must be marked IMMUTABLE

Rewrite it as a half-open range against the raw column instead, which the existing index navigates directly:

 Index Scan using orders_merchant_created_inc_status_idx on orders (actual time=0.036..6.962 rows=1924.00 loops=1)
   Index Cond: ((merchant_id = 42) AND (created_at_utc >= '2025-02-11 00:00:00+00'::timestamptz) AND (created_at_utc < '2025-02-12 00:00:00+00'::timestamptz))
   Buffers: shared hit=1936

19,261 buffers down to 1,936, and the same 1,924 rows.

3. Change the index type when the operator is the obstacle. A leading-wildcard LIKE needs a trigram GIN index; a jsonb containment test needs GIN. Adding the column to a B-tree will not move that predicate into Index Cond.

4. Accept it. If the filter discards little, leave it. The LIKE example removed 57 rows in 80 buffers; an index for that predicate would be maintained on every write for no measurable read benefit.

How to prevent it

Watch the ratio, not the presence of the word. Read every Rows Removed by Filter as a multiplier: divide it by the node's rows, treat anything past roughly 10x as worth a second look and past 100x as probably a missing index column. That one arithmetic step separates a filter that costs nothing from one reading a thousand rows per row returned.

Turn on automatic plan capture before you need it. Across 50 monitored instances, 86% are not capturing plans automatically; when the pager goes off at 03:00 and the query is fast again by 09:00, the counter from the slow run no longer exists anywhere.

Check the estimate as well as the counter — when a node's actual rows are far from its estimate, the planner chose this shape on bad information, so run ANALYZE and read how the planner uses table statistics first. And review what you add: across 31 monitored instances, 58.1% have unused indexes and 67.7% have duplicate ones, while only 3.2% fail the missing-index check. On this fleet, over-indexing is the commoner mistake.

FAQ

Is Filter in a plan always bad?

No. Filter on a sequential scan is how a sequential scan works, and a filter discarding a handful of rows costs almost nothing. It is worth investigating when Rows Removed by Filter is large relative to the node's returned rows, and the node's Buffers count is large with it.

Why is my indexed column showing up in Filter?

Almost always because the predicate does not match the index expression — a cast, a function call, or an implicit collation difference — or because the operator has no entry in that index's operator class. Compare the Filter line's exact text with \d tablename; any difference means the index cannot be navigated with it.

What is the difference between Filter and Recheck Cond?

Recheck Cond belongs to bitmap heap scans only and re-applies the index condition for pages whose bitmap entries lost per-tuple detail; its rejects are Rows Removed by Index Recheck. Filter is a predicate no index covered. A bitmap heap scan can print both lines at once, for two different conditions.

Why does my INCLUDE column appear in Filter rather than Index Cond?

Because INCLUDE columns are payload, not keys: they are stored in the index but take no part in its ordering, so nothing can be navigated with them. On an index-only scan the filter is still evaluated inside the index — Heap Fetches: 0 and a small Buffers count together mean the removed rows were cheap.

Does Rows Removed by Filter appear without ANALYZE?

No. Plain EXPLAIN prints the Filter line, since that is part of the chosen plan, but the counter comes from a real execution — as do Rows Removed by Join Filter and Rows Removed by Index Recheck.

Part of the Reading PostgreSQL EXPLAIN and EXPLAIN ANALYZE Output guide. Last verified against PostgreSQL 18, 2026-09-17.