PostgREST 12.2: Prometheus metrics
PostgREST 12.2 adds Prometheus-compatible metrics for its schema cache and connection pool, such as pgrst_db_pool_timeouts_total, to help diagnose problems like pool starvation. Function-level settings such as statement_timeout are now "hoisted" and applied per transaction when the function is called through RPC, so a single function can have its own timeout without changing the API role for every statement. Other settings can be added to the hoisted list via db-hoisted-tx-settings. A new max-affected Prefer header caps how many rows a mutation can touch, returning PGRST124 when the cap is exceeded under strict handling.
Related posts
- What is new in PostgREST v11.1?
Supabase mediumAdeptPostgREST 11.1 lets impersonated JWT roles (anon, authenticated, service_role) carry Postgres settings via ALTER ROLE ... SET, applied after a NOTIFY pgrst 'reload config'. That enables per-role statement_timeout and pg_plan_filter cost limits, where the cost limit rejects expensive queries at planning time but needs careful tuning. Transaction isolation is now configurable per function or role, alongside bulk JSON inserts that respect column defaults and new any/all filter modifiers. Breaking changes from v10 are small: the Range header is ignored on non-GET requests and Prefer: params=multiple-objects is dropped for RPC, and usage logs show almost no projects relied on either.
- PostgREST 12
Supabase mediumAdeptPostgREST 12 caches validated JWTs using the token's exp claim as the cache lifetime, cutting server-side JWT handling in the example from about 148ms to 14ms per request. A new Server-Timing response header reports per-phase durations for jwt, parse, plan, transaction and response. The release also adds aggregate functions (avg, count, max, min, sum) with implicit group-by through the select clause, plus media type handlers that let SQL functions return custom content types such as HTML directly from Postgres.
- Own Your Observability: Supabase Metrics API
Supabase mediumAdeptSupabase's Metrics API exposes roughly 200 Postgres health and performance metrics per project in Prometheus exposition format at a privileged endpoint authenticated with service-role Basic Auth, refreshed every minute. It can be scraped by Grafana Cloud, Datadog, AWS Managed Prometheus or any Prometheus-compatible backend, so database telemetry can be correlated with existing application observability. Suggested signals and alerts include connection saturation, CPU/memory above 80%, disk I/O wait, replication lag and post-deploy query regressions, plus using PgBouncer for bursty connection patterns.
- 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.
- 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.