Server-side for PostgreSQLs
Server-side programming means putting logic inside the database. PostgreSQL lets you write functions and procedures in PL/pgSQL, create triggers that fire on row changes, define views and materialised views, and use stored computation close to the data. It cuts network round trips but needs careful testing and version control.
Stage: Programming and Extensions · Part of the PostgreSQL roadmap · Last reviewed 19 November 2026
What to learn in Server-side
- Write a PL/pgSQL function that takes parameters and returns a value
- Create a trigger that records changes into an audit table
- Define a view to simplify a repeated join
- Refresh a materialised view and explain when to use it
- Decide when logic belongs in the database rather than the application
Server-side interview questions
What is the difference between a view and a materialised view?
A view stores only a query and runs it each time it is read. A materialised view stores the query result physically, so reads are fast but the data is stale until you run REFRESH MATERIALIZED VIEW.
When is a trigger a poor choice?
Triggers run invisibly, which can surprise developers, slow bulk writes, and make debugging hard. They suit audit logs and enforcing invariants, but business logic that changes often is usually clearer and easier to test in application code.
Where Server-side fits in the PostgreSQL roadmap
Server-side belongs to the Programming and Extensions stage (intermediate level). Extend the database.
Other units in this stage
Back to the full PostgreSQL roadmap