docs(scale): correct F1 — table-facts RPC slowness is a generic plan + verified one-line fix#391
Merged
Merged
Conversation
… the predicate
Re-profiled live (read-only). The % rewrite this section recommended is ALREADY
on live and did not help: each arm is fast (0.36/5.5/158 ms) and the full body
with a literal runs in 70 ms, but the RPC call is 5.3 s. Root cause: the
function is LANGUAGE sql + SET search_path (non-inlinable), so it runs a generic
plan for an unknown $1 and can't estimate trigram/tsv selectivity.
Fix (pure-performance, results identical, no eval gate):
alter function public.match_document_table_facts_text(text,integer,uuid[],uuid)
set plan_cache_mode = 'force_custom_plan';
Verified 5.3 s -> ~1.1 s (4.8x). Same one-liner for the other non-inlined hybrid
RPCs. Full 75x fix = convert to plpgsql + RETURN QUERY EXECUTE (needs the drifted
body reconciled first). Body-agnostic ALTER, so it does not collide with the
separate schema.sql<->live body/return-signature drift on this RPC.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
BigSimmo
enabled auto-merge
July 8, 2026 08:42
Copilot stopped work on behalf of
BigSimmo due to an error
July 8, 2026 08:42
Copilot stopped work on behalf of
BigSimmo due to an error
July 8, 2026 08:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Corrects the F1 finding in
docs/scale-readiness-review.mdafter re-profiling live (read-only). My original F1 diagnosis was wrong, and the fix it recommended (rewrite the fuzzy disjunct to the%operator) is already on live and did not help.What's actually happening
match_document_table_facts_textalready uses the bounded-CTE +%form. Each arm is fast in isolation (tsv@@0.36 ms,normalized_terms &&5.5 ms, trigram%158 ms), and the full body with a literal query runs in 70 ms.LANGUAGE sql STABLEwithSET search_path→ non-inlinable → its body is planned once with an unknown$1, so the planner can't estimate trigram/tsv selectivity and picks near-seq-scan strategies. Every call pays that generic plan.SET plan_cache_mode = force_custom_plandrops it 5.3 s → ~1.1 s (≈4.8×).The fix (pure performance — results byte-identical, no eval gate)
Body-agnostic (targets the function by argument signature), so it does not collide with the separate schema.sql↔live body/return-signature drift on this RPC (that reconciliation belongs to the drift backlog). Same one-liner applies to the other non-inlined hybrid RPCs (memory-cards, index-units, embedding-fields). A full ≈75× fix (→ ~70 ms) needs converting to
plpgsql+RETURN QUERY EXECUTE, after the drifted body is reconciled.Why docs, not a migration
Applying to live needs the linked
supabaseCLI (operator credentials — not authenticated in this environment) and the migration policy forbidsdb pushon this project's divergent history. TheALTER FUNCTIONabove is a safe, results-identical, one-line change you can run in the dashboard SQL editor or land as a committed migration when you next apply migrations.Refs #339
🤖 Generated with Claude Code