Skip to content

Expose monitor schema to Supabase admin#747

Open
jingsam wants to merge 1 commit into
pgsty:mainfrom
jingsam:codex/supabase
Open

Expose monitor schema to Supabase admin#747
jingsam wants to merge 1 commit into
pgsty:mainfrom
jingsam:codex/supabase

Conversation

@jingsam
Copy link
Copy Markdown
Contributor

@jingsam jingsam commented May 18, 2026

Summary

  • keep pg_stat_statements in Pigsty's monitor schema for pg_exporter compatibility
  • add monitor to the supabase_admin search_path in the Supabase baseline SQL

Reason

The Supabase docker compose in this repo runs postgres-meta with PG_META_DB_USER=supabase_admin, and Studio calls postgres-meta for dashboard database features. Supabase Query Performance uses unqualified pg_stat_statements queries, while Pigsty creates pg_stat_statements in the monitor schema for its PostgreSQL monitoring stack. Adding monitor to supabase_admin's search_path lets Supabase Query Performance find pg_stat_statements without moving the extension away from the schema expected by pg_exporter.

Tests

  • Parsed conf/supabase.yml with Ruby YAML loader.
  • Not run; configuration/baseline SQL change only.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2432fc372

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread conf/supabase.yml Outdated
- { name: intagg ,schema: extensions }
- { name: intarray ,schema: extensions }
- { name: pg_repack ,schema: extensions }
- { name: pg_stat_statements ,schema: extensions }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep pg_stat_statements reachable for pg_exporter

When Supabase uses the bundled PostgreSQL monitoring, this creates pg_stat_statements only in extensions, but the generated init SQL still sets the monitor user search path to monitor,public (roles/pgsql/templates/pg-init-template.sql:111) and pg_exporter connects as that user (roles/pg_monitor/templates/pg_exporter.env:7) while running unqualified FROM pg_stat_statements(false) queries (roles/pg_monitor/templates/pg_exporter.yml:1331). Those collector queries will fail with “function does not exist” for Supabase deployments unless the monitor search path is also updated or the exporter queries are schema-qualified, so query-performance metrics are lost.

Useful? React with 👍 / 👎.

@jingsam jingsam changed the title Place Supabase pg_stat_statements in extensions schema Expose monitor schema to Supabase admin May 19, 2026
Copy link
Copy Markdown
Contributor Author

jingsam commented May 19, 2026

Please do not merge this PR yet.

I tested the current approach and it does not actually fix Supabase Query Performance. The reason is that Supabase Studio hard-codes the query performance SQL with:

set search_path to public, extensions;

and then runs unqualified queries against pg_stat_statements. Because of that explicit SET search_path, changing supabase_admin's role-level search_path is overridden and does not make monitor.pg_stat_statements visible to Supabase Studio.

So the current PR is ineffective. The underlying conflict is:

  • Supabase Query Performance expects pg_stat_statements to be reachable via public, extensions, effectively requiring it in extensions for this template.
  • Pigsty's pg_exporter currently expects unqualified pg_stat_statements to remain reachable for the monitor user, and the existing default places it in the monitor schema.

Could you suggest the preferred direction here? For example, should the Supabase template move pg_stat_statements to extensions and also adjust monitor compatibility for pg_exporter, or is there a better Pigsty-side pattern for supporting both Supabase Studio and pg_exporter?

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.

1 participant