PostgREST v10: EXPLAIN and Improved Relationship Detection
PostgREST 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.
Related posts
- Cracking PostgreSQL Interview Questions
Supabase mediumAdeptInterview preparation for the transactional side of PostgreSQL, organized around five areas: data modeling, indexes, views, roles and functions. It covers modeling 1-1, 1-M and M-M relationships with foreign keys and join tables, and using rich types like JSONB, enums and timestamptz. On performance and access control it explains B-tree and other index types, comparing plans with EXPLAIN ANALYZE, auto-updatable views, GRANTs to PUBLIC, and row level security policies. It also shows PL/pgSQL trigger functions for auto-updating timestamps, advises thinking in sets rather than loops, and introduces CTEs, all with short SQL examples.
- Supabase CLI
Supabase mediumAdeptSupabase's new CLI runs the full Supabase stack locally via Docker Compose, using the same tooling as production, and walks through wiring it to a React app. For migrations, Supabase prefers schema diffing over hand-written migration scripts. After evaluating migra, dbdiff, pgdiff, apgdiff, pgquarrel and pgAdmin Schema Diff, it picked pgAdmin's because it tracks VIEW owner changes, which Row Level Security on views depends on, and it also handles domains. Since pgAdmin's diff was GUI-only, Supabase built a CLI mode for it and shipped it as a Docker image. A `supabase eject` command emits docker-compose, Kong and Postgres configs for self-hosting.
- Declarative Schemas for Simpler Database Management
Supabase mediumAdeptSupabase CLI now supports declarative schemas: the desired final state of Postgres tables, views, functions, RLS policies, grants and types lives in versioned .sql files, and a schema diff tool such as migra generates the migration files. Supabase used this internally for two years on its complex projects table, which sits in a private schema behind a public view with RLS-based ABAC and INSTEAD OF triggers. Previously, adding one column meant hand-copying view and trigger definitions into a migration of several hundred lines that conflicted often. Now it is a one-line diff, and generated migrations still get manual review. The team says this cut schema changes from hours to minutes and made rebasing much easier.
- pg_graphql: A GraphQL extension for PostgreSQL
Supabase mediumAdeptpg_graphql is an open-source PostgreSQL extension, written in C and SQL, that reflects a GraphQL schema from existing tables and resolves queries entirely inside the database. Supabase built it because its 1 GB free-tier VMs had no memory left for a separate GraphQL process like Graphile or Hasura. Each GraphQL request is transpiled into a single SQL statement that aggregates results as JSON. This avoids N+1 queries, respects row level security, and gives multi-operation requests transactional semantics. Pagination follows the Relay connection spec using keyset pagination, the API is one SQL function (gql.resolve) exposed over HTTP via PostgREST, and a benchmark shows about 2,205 requests/second on a 4-core machine.
- 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.