Postgres Changes gets AND filters, new operators, and column selection
Supabase Realtime's Postgres Changes subscriptions now support AND-composed filters across multiple columns, new operators (like, ilike, is, match/imatch for POSIX regex, isdistinct, and not. negation), a typed filter builder, and a select option that returns only chosen columns plus the primary key. Server-side filtering and trimmed payloads cut billable messages and egress, since each delivered change counts per subscriber. Column selection needs supabase-js 2.109.0+, RLS still applies, DELETE events can't be column-filtered because they carry only the primary key, and OR composition, JSON/array containment, full-text and range operators remain unsupported.
Related posts
- Realtime: Broadcast from Database
Supabase mediumAdeptSupabase Realtime's Broadcast from Database sends database change events to clients through Postgres triggers that write to a `realtime.messages` table. Realtime reads that table via a replication slot on its WAL publication and broadcasts each new row to the target channel immediately. Compared with polling-based Postgres Changes it needs more setup (RLS policies, a trigger function using `realtime.broadcast_changes` or `realtime.send`, and private channels on the client). In return it can target specific operations, send only chosen columns, route messages to channels with SQL, and scale to tens of thousands of concurrent subscribers. `realtime.send` catches exceptions and reports errors via `pg_notify`, so a failed send does not break the trigger.
- PostgREST 11 pre-release
Supabase mediumAdeptPostgREST 11's pre-release, available through the Supabase CLI, adds three querying features. A spread operator (`...table(cols)`) flattens embedded related-table columns into the parent object. Ordering by a related table's column is now supported, as are anti-joins via `is.null` filters on embedded resources. Spread and related ordering work only for one-to-one and many-to-one relationships for now. A `not.is.null` filter provides a more flexible alternative to the `!inner` modifier because it can be combined with `or` filters.
- Realtime Postgres RLS now available on Supabase
Supabase mediumAdeptSupabase Realtime now enforces PostgreSQL Row Level Security on change broadcasts. Previously every database change went to every client. A new in-database function, WALRUS, takes each logical replication record, finds active subscribers from a subscription table, assumes each subscriber's identity and checks visibility with a primary-key lookup. Prepared statements remove query planning cost, which is often 2-3x execution time for simple queries, and colocating the check in Postgres avoids network round trips. Per-record processing grows from about 11 ms with 1 subscriber to about 304 ms with 10,000. Recommendations: skip RLS on public tables, keep policies index-backed and join-free, and use small fixed-size primary keys.
- PostgREST 9
Supabase mediumAdeptPostgREST 9 adds inner-join resource embedding via the `!inner` keyword, so top-level rows can be filtered by conditions on an embedded table (e.g. messages filtered by users.username). Functions can now accept a single unnamed JSON parameter, which lets webhooks such as Postmark bounce notifications POST raw payloads straight to an rpc endpoint. PostgreSQL 14 compatibility forced a breaking change: per-claim and per-header settings are replaced by `request.jwt.claims` and `request.headers` JSON settings, so custom auth functions must be updated. Supabase's built-in auth helpers already handle this.
- SQL or NoSQL? Why not use both (with PostgreSQL)?
Supabase mediumAdeptPostgreSQL's JSONB columns let an app store nested, variable-length data (here, a daily food, water and exercise log) as a single row instead of spreading it across several normalized tables, while keeping SQL available for analysis. A worked example builds a calendar table with JSONB log fields and inserts a whole day in one statement. It then uses jsonb_array_elements with the -> and ->> operators to flatten the arrays into rows. Because aggregates cannot wrap set-returning functions, the flattened query goes into a CTE before summing daily calories or filtering for specific items.