Database

Postgres: connecting, Studio, tables, functions, extensions, migrations and performance.

20 pages · start with Postgres on SupaHost

  1. 01Postgres on SupaHostHow Postgres is laid out on SupaHost: one Postgres 17 server per instance, one database per project, shared quotas, roles, connections, backups and what isn't offered.
  2. 02Connecting to your databaseEvery way to reach a SupaHost project's Postgres database, per plan: the Data API, Studio's SQL editor, MCP execute_sql, and direct Postgres over an SSH tunnel on Business.
  3. 03Using Supabase StudioHow to open Supabase Studio for a SupaHost project, what works in it (table editor, SQL editor, Auth, Storage, policies), what's switched off, and how sessions work.
  4. 04Tables, columns and dataCreate and change tables in a SupaHost project with Studio or SQL: column types, primary keys, foreign keys, constraints, and making tables safe to reach through the Data API.
  5. 05JSON and JSONB columnsStore, query, filter, update and index JSON data in a SupaHost project, from SQL and through the Data API with supabase-js, and when a regular column is the better choice.
  6. 06Row Level SecurityProtect data exposed through the Data API with Postgres Row Level Security: enabling it, writing policies with auth.uid() and auth.jwt(), team access, testing and performance.
  7. 07Database functionsWrite Postgres functions in SQL and PL/pgSQL on SupaHost, choose security invoker or definer, set a safe search_path, control who can execute them, and call them from your app.
  8. 08TriggersRun Postgres functions automatically when rows change in a SupaHost project: updated_at timestamps, creating profiles on sign-up, audit logs, and avoiding common trigger mistakes.
  9. 09Database webhooks and HTTP requests with pg_netSend HTTP requests from Postgres on SupaHost: database webhooks that post row changes to a URL or Edge Function, direct pg_net calls, reading responses and debugging.
  10. 10Postgres extensionsWhich Postgres extensions you can use on SupaHost, how to list, enable and remove them per project, and the special cases: pg_cron is built in, pg_net and dblink are preinstalled.
  11. 11Full-text searchAdd keyword search to a SupaHost project with Postgres tsvector columns, GIN indexes and websearch queries, then call it from supabase-js with textSearch or an RPC.
  12. 12IndexesWhich Postgres index to add and when on SupaHost: B-tree, composite, partial, GIN, BRIN and expression indexes, building them without locking, and finding unused ones.
  13. 13Query performance and EXPLAINFind and fix slow queries in a SupaHost project: read EXPLAIN ANALYZE plans, test queries under RLS as a real user, use pg_stat_statements, and apply the usual fixes.
  14. 14Roles and permissionsThe Postgres roles in a SupaHost project (postgres, anon, authenticated, service_role and the service roles), how grants and RLS work together, and how to add your own roles safely.
  15. 15Connections and timeoutsHow database connections are shared on a SupaHost instance (max_connections 400, small per-project pools, no pooler) and how to check and set statement timeouts per role, function or session.
  16. 16Storing secrets with VaultKeep API keys and tokens encrypted inside your SupaHost project's database with Supabase Vault, and read them from SQL functions, triggers, pg_net calls and cron jobs.
  17. 17Importing data (CSV, SQL dumps)Load data into a SupaHost project from CSV files, SQL scripts or pg_dump archives, using Studio, a supabase-js script, psql and pg_restore over the Business SSH tunnel, or the Supabase Cloud import.
  18. 18Geo data with PostGISStore locations in a SupaHost project with PostGIS, insert points from supabase-js, index them with GiST, and run nearby and within-area queries through RPC functions.
  19. 19Table partitioningSplit large time-series or tenant tables into partitions in a SupaHost project with Postgres declarative partitioning, keep RLS safe, create partitions with pg_cron and drop old data cheaply.
  20. 20SQL migrationsChange a SupaHost project's schema with versioned SQL migrations: how history is tracked, applying them over MCP, in Studio or with psql on Business, and testing on a branch first.