Skip to content

perf: Decode the schema argument only on a callsite cache miss - #104

Merged
imor merged 1 commit into
supabase:masterfrom
Stranger6667:dd/schema-arg-raw
Sep 30, 2026
Merged

imor merged 1 commit into
supabase:masterfrom
Stranger6667:dd/schema-arg-raw

Conversation

@Stranger6667

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Performance follow-up on compiled schemas

What is the current behavior?

The compiled-schema functions decode the jsonschema argument on every call, even when the callsite already holds its validator.

What is the new behavior?

The callsite cache is keyed on the argument's stored bytes (for a large schema, a TOAST pointer). The schema is decoded only on a cache miss.

Additional context

With the FHIR schema (3.2 MB) over 10k rows:

  • as a constant, 956 ms -> 147 ms;
  • from a table column, 31.9 s -> 111 ms.

@imor

imor commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

@Stranger6667 I merged #106 first, can you please fix the merge conflicts?

Signed-off-by: Dmitry Dygalo <dmitry@dygalo.dev>
@Stranger6667
Stranger6667 requested a review from a team as a code owner September 30, 2026 11:28
@imor
imor merged commit 1bbfad8 into supabase:master Sep 30, 2026
3 checks passed
@Stranger6667
Stranger6667 deleted the dd/schema-arg-raw branch September 30, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants