Every Supabase project comes with a full PostgreSQL database, one of the world’s most stable and advanced relational databases. Supabase extends Postgres with real-time functionality, automatic APIs, and a suite of powerful extensions.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/supabase/supabase/llms.txt
Use this file to discover all available pages before exploring further.
Architecture
Supabase Database is built on PostgreSQL with several key components:- PostgreSQL Core: Your database runs on a dedicated Postgres instance with full
postgreslevel access - PostgREST: Automatically generates a RESTful API from your database schema
- pg_graphql: Provides a GraphQL API for your data
- Realtime Server: Broadcasts database changes via WebSockets
- postgres-meta: A RESTful API for database management operations
Core Concepts
Tables and Schemas
PostgreSQL organizes data into tables within schemas. Supabase creates several schemas by default:public: Your application tables (exposed via auto-generated APIs)auth: User authentication data (managed by Supabase Auth)storage: File metadata (managed by Supabase Storage)extensions: PostgreSQL extensionsrealtime: Real-time configuration
Row Level Security (RLS)
RLS is PostgreSQL’s built-in authorization system that allows you to control access to individual rows in your tables. Supabase enables RLS by default on new tables.Relationships
PostgreSQL supports foreign keys to define relationships between tables:Indexes
Indexes improve query performance by allowing the database to find data without scanning every row:Auto-generated APIs
Supabase automatically generates RESTful and GraphQL APIs from your database schema:REST API (PostgREST)
GraphQL API
Database Functions
You can create custom functions in PostgreSQL to encapsulate business logic:Triggers
Triggers automatically execute functions in response to database events:Extensions
Supabase provides access to over 50 PostgreSQL extensions. Enable them with a single click in the Dashboard:Popular Extensions
- pgvector: Store and query vector embeddings for AI applications
- PostGIS: Geographic information system capabilities
- pg_cron: Schedule periodic jobs
- uuid-ossp: Generate UUIDs
- pg_stat_statements: Track query performance
Database Management
Migrations
Use migrations to version control your database schema:Backups
Supabase manages automated backups for your database:- Free tier: Daily backups retained for 7 days
- Pro tier: Daily backups retained for 14 days
- Team tier: Daily backups retained for 28 days
- Enterprise: Custom retention periods and Point-in-Time Recovery (PITR)
Performance Optimization
Connection Pooling
Supabase uses PgBouncer for connection pooling. You can access your database through two connection modes:- Session mode (Port 5432): Full PostgreSQL features, limited connections
- Transaction mode (Port 6543): Higher concurrency, some feature limitations
Query Performance
Use the SQL Editor to analyze query performance:Vacuum and Analyze
PostgreSQL automatically performs vacuum operations, but you can manually optimize:Best Practices
Use RLS
Always enable Row Level Security and create appropriate policies for your tables.
Index Strategically
Create indexes on columns used in WHERE clauses and JOIN conditions.
Normalize Data
Design tables following database normalization principles to reduce redundancy.
Use Transactions
Wrap related operations in transactions to ensure data consistency.
Next Steps
Database Functions
Learn how to create custom database functions
Triggers
Automate database operations with triggers
Extensions
Extend PostgreSQL with powerful extensions
Migrations
Version control your database schema
