Inquiry: Handling Schema Cache for frequent dynamic table creation in v14.x (PGRST205)
Context
We are seeking guidance on the intended behavior of the schema cache in PostgREST v14.3, specifically regarding how it handles newly created tables.
We operate a multi-tenant platform with ~67,000 relations, where tables are created dynamically at a rate of several per minute. We've noticed a change in behavior starting around v14.x that impacts our workflow, and we want to ensure we are following the recommended patterns for the latest versions.
Observation
In versions prior to v14 (e.g., v11.1, v12.2), newly created tables appeared to become accessible without requiring an immediate, explicit manual schema reload.
However, in v14.3, any request to a newly created table returns a 404 Not Found with error PGRST205:
{
"code": "PGRST205",
"details": null,
"hint": null,
"message": "Could not find the table 'abcdef12345678' in the schema cache"
}This indicates that the table exists in PostgreSQL but is missing from PostgREST’s schema cache at request time.
Challenge for scaling
While a manual reload resolves the PGRST205 error, our schema size makes this too costly. Based on our logs:
- Schema cache query time: ~7.7 seconds
- Total reload/processing time: ~150ms (after query)
- Total "blocking" time: ~30 seconds in practice for the full cycle
Given our rate of table creation (multiple per minute), triggering a full reload for every new table creates a backlog of reload requests and is not viable for our case. This seems to conflict with the excellent loading performance optimizations introduced in the v14.x series.
Questions
Given the optimizations in #4360 and #4462, we would like to understand the expected architectural pattern:
Is this behavior change intentional? In v14.x, is it now a requirement for the orchestrator to explicitly notify PostgREST of every schema change to avoid PGRST205? (schema cache reloading practices were discussed in #4463).
Are there recommended strategies for high-volume, dynamic table creation? For environments with 60k+ relations, is there a way to let PostgREST "discover" a single missing table or perform a partial refresh without a full cache rebuild?
Was an implicit fallback removed? Was there previously a "retry on cache miss" mechanism that has been phased out to prioritize performance?
Based on the changelog, the most relevant changes between v14.0 and v14.3 seem to be:
v14.3:
Fix performance and high memory usage of relation hint calculation by @mkleczek in
#4462, #4463v14.0:
Fix schema cache loading taking a long time for large schemas by @mkleczek in
#4360, #3704
Environment
- PostgREST version affected: v14.3
- PostgREST versions NOT affected: at least v11.1.0, v12.2.3, and a custom build of this orphan branch based on ~v14.0 (as referenced in #4462)
- PostgreSQL version: 15.15
- Number of tables: ~67,000 relations
Workaround
We have temporarily reverted to using this orphan branch build, which restores the expected behavior and does not require manual schema cache reloads. We would, however, prefer to move back to the main release line if we can align our reload strategy with the v14 architecture.
Source: PostgREST/postgrest