PostgREST 11 pre-release
PostgREST 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.
Related posts
- 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.
- PostgREST 13
Supabase mediumAdeptPostgREST 13 adds spread syntax for to-many relationships so one-to-many and many-to-many joins can be returned as flat JSON arrays, automatic to_tsvector conversion that enables full text search on text and json/jsonb columns (backed by a GIN index on the expression), and a maxAffected limit that throws an error when an update, delete or rpc touches too many rows. For observability, responses now carry Content-Length and a Proxy-Status header with the PostgREST error code. Breaking changes: JWT kid claims are validated against the configured JWKS, and schemas in db-schemas and db-extra-search-path must exist, so schema drops should update the search path in the same transaction.
- PostgREST Aggregate Functions
Supabase mediumAdeptPostgREST v12 adds on-the-fly aggregate functions (avg, count, max, min, sum) to its API. You apply them by appending the function to a column in the select parameter, and any non-aggregated columns become implicit GROUP BY columns. Aggregates compose with column renaming, filtering, embedded resources and spread relationships, so you can group movies by a related director's country, for example. Because aggregates bypass pagination limits and can be abused for denial of service, the feature is disabled by default. Before enabling it, set per-role query cost ceilings with pg_plan_filter.
- Postgres Changes gets AND filters, new operators, and column selection
Supabase mediumAdeptSupabase 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.
- PostgREST v10: EXPLAIN and Improved Relationship Detection
Supabase mediumAdeptPostgREST v10 adds HTTP-level EXPLAIN support: requests with the `application/vnd.pgrst.plan` media type, or supabase-js's `explain()` transform, return the PostgreSQL execution plan for reads, writes and RPC, which helps verify that RLS policies are applied and gives you the pg_stat_statements query identifier. Relationship detection also improves. One-to-one relationships are inferred from unique or primary keys on foreign keys, and "computed relationships" use inlinable SQL functions to define joins on views and materialized views that lack foreign keys. A breaking change now requires a join table's primary key to include both foreign key columns before it is detected as many-to-many. EXPLAIN is gated behind `db-plan-enabled` and intended only for development.