Database / Supabase basics Interview Questions
When should you use an Edge Function instead of a Postgres database function?
Both let you run custom logic, but they suit different jobs. A Postgres function (written in SQL or PL/pgSQL and callable via RPC) is the right choice when the logic is fundamentally about data: aggregations, multi-table transactions, or anything that benefits from running inside the database's own transaction boundary.
An Edge Function is the better fit when the logic needs to reach outside the database: calling a third-party REST API, verifying a webhook signature, sending an email through an external provider, or using a secret credential that shouldn't live inside SQL. Edge Functions also make sense when you need a general-purpose runtime (npm packages, async HTTP calls) rather than SQL's more limited procedural surface.
A common pattern combines both: a database trigger calls a webhook that invokes an Edge Function, so a data change (like a new order row) triggers external side effects (like a payment charge) without the client needing to orchestrate the sequence itself.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
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.
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! Receive free stock by signing up using the link: Webull signup.
More Related questions...
