Prev Next

Database / Supabase Intermediate to Advanced Interview Questions

Explain the execution flow of a private Realtime broadcast channel authorized by Row Level Security?

A private Realtime channel starts the same way a public one does — a client calls supabase.channel('room-42', { config: { private: true } }) and attempts to subscribe — but before any messages flow, the Realtime server checks whether that connection's JWT is authorized for this specific channel, rather than allowing any authenticated client onto any channel name.

  1. The client establishes a WebSocket connection to Realtime, presenting its JWT.
  2. On a subscribe attempt to a private channel, Realtime queries a Postgres function (or checks a realtime.channels-linked RLS policy) to determine whether this user is authorized for that channel name.
  3. If the check passes, the subscription is accepted and the client starts receiving Broadcast or Presence events published to that channel; if it fails, the subscription is rejected before any data is sent.
  4. Every subsequent message published to the channel is delivered only to connections that passed this authorization step, rather than to every WebSocket connected to the server.

This differs from the plain "Postgres Changes" channel type, where authorization is enforced per-row via table RLS on every change event; a private broadcast/presence channel instead authorizes at the channel-subscription level, once, up front — useful for scenarios like a chat room or collaborative document where the "row" being protected isn't a single table row but an entire logical room.

At what point is a private Realtime channel's authorization check performed?
How does private channel authorization differ from the Postgres Changes channel's row-level RLS?

Invest now in Acorns!!! 🚀 Join Acorns and get your $5 bonus!
Acorns Logo

Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!

Earn passively and while sleeping

Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.

Robinhood Logo

Invest now!!! Get Free equity stock (US, UK only)!

Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.

The Robinhood app makes it easy to trade stocks, crypto and more.


Webull Logo

Webull! Receive free stock by signing up using the link: Webull signup.

More Related questions...

How does Supabase expose custom Postgres functions as callable RPC endpoints? What is the difference between a SECURITY DEFINER and a SECURITY INVOKER Postgres function? How does pg_cron enable scheduled jobs directly inside a Supabase Postgres database? What is the difference between a read replica and the primary database in a Supabase project? When should you use a read replica versus scaling the primary database's resources? What is the difference between daily backups and Point-in-Time Recovery in Supabase? How does Supabase's database branching feature isolate schema changes per git branch? When would you choose a preview branch over testing migrations directly in staging? What is the difference between a custom access token hook and a raw JWT claim? Why should you avoid embedding sensitive business data directly inside JWT claims? How does Supabase support anonymous sign-ins, and how do you convert one to a permanent account? What is the difference between linking an OAuth identity and creating a brand-new user account? How is Storage object access controlled compared to table-level Row Level Security? What is the difference between resumable (TUS) uploads and standard uploads in Supabase Storage? How does Supabase's image transformation feature resize images without a separate CDN service? What is the difference between LISTEN/NOTIFY and Supabase Realtime's Postgres Changes channel? What is the difference between schema-per-tenant and RLS-based multi-tenancy? Why is EXPLAIN ANALYZE useful before optimizing a slow Supabase query? What is the difference between JSONB and a fully normalized relational schema in Postgres? When should you use a JSONB column instead of creating additional relational tables? How does wrapping auth.uid() in a subquery improve Row Level Security performance? Why do we use SECURITY DEFINER functions when RLS would otherwise block a needed operation? How does pg_net let Postgres make asynchronous HTTP calls without blocking a transaction? Explain the lifecycle of a Point-in-Time Recovery (PITR) backup in Supabase? How does a custom access token Auth Hook let you enrich a user's JWT with custom claims? How does Supabase enforce multi-factor authentication (MFA) at the session level? Why doesn't disabling RLS on a table make it invisible in the auto-generated API docs? Explain the internal working of Supabase Vault for storing encrypted secrets in Postgres? Why should you store third-party API keys in Vault instead of a plain table column? When should you choose LISTEN/NOTIFY over Supabase Realtime for internal service communication? How can you optimize a multi-tenant schema design using Row Level Security instead of schema-per-tenant? How do you troubleshoot a Postgres query that performs well in the SQL editor but slowly through the REST API? Explain the execution flow of a private Realtime broadcast channel authorized by Row Level Security? Why do private Realtime channels need their own RLS-style authorization check? How does Supabase's connection string differ between the direct connection, session pooler, and transaction pooler? Why doesn't the transaction pooler support prepared statements the way a direct connection does? How can you optimize zero-downtime schema migrations for a table already receiving production traffic? What happens when a long-running migration locks a table that's still receiving live writes? How does Supabase Studio's SQL editor differ from running migrations through the CLI in a CI pipeline? Which is better for production schema changes, editing directly in Studio or CLI-managed migrations, and why?
Show more question and Answers...

Integration

Comments & Discussions