Skip to content

PostgreSQL

Start with two workers reaching for the same job. See when to wake a worker, then follow two shops as they read and update pickups and move their report to a view. The standalone guides cover a lost reply, a job saved with its order, and a slow search through completed pickups.

Queues and transactions

  1. One worker slots the only envelope into outgoing mail. The other hand waits over an empty tray.

    Wait, you can put functions in Postgres?

    Write a PostgreSQL function and call it with SELECT. Follow a job queue example to see what happens when two workers call it together.

  2. A worker presses one red button beneath two docked drones with lit amber lamps.

    How Postgres wakes a worker with LISTEN and NOTIFY

    Use three database sessions to see when PostgreSQL delivers a notification, what two listeners receive, and how a worker recovers jobs on reconnect.

Database access and row security

  1. Two report trays sit side by side. One holds pickups marked with a green circle. The other holds pickups marked with an ochre square.

    PostgreSQL row-level security for reads and writes

    See how grants and row policies work together, from filtering reads to checking the row an update would save.

  2. A worker faces two warehouse windows, one marked with a key and the other with Cedar's green circle.

    Whose permissions does a PostgreSQL view use?

    Compare an ordinary view and a security invoker view to see whose table privileges and row policies apply. Then expose just two columns to support.

Articles

  1. Two matching stamped slips sit above one cardboard package.

    Idempotent inserts in PostgreSQL

    Use a unique key and ON CONFLICT to deduplicate retries. See what the app can return after a lost reply or a concurrent insert.

  2. A worker slides shut one drawer holding an order slip and a pickup slip side by side.

    The transactional outbox in PostgreSQL

    Commit application data and a queued job together so the worker can find pending work after a crash, restart or missed notification.

  3. A hand reaches for two orange-tagged packages in a single section of a warehouse shelf.

    Partial indexes for PostgreSQL job queues

    See when a partial index can save work in a job queue, using two query plans and the position of the first pending job.

Keep reading