Skip to main content

purge_all_messages

SQL 0.1.1 · Source cbff27b8a34e1384384018680e46c20d5c610cc9.

Signature​

postgremq.purge_all_messages()
RETURNS void

The signature, defaults, and result above were extracted from the installed PostgreSQL catalog.

Discard all queue message data​

Deletes all dead-letter entries, queue delivery rows, and payloads across the installation, then prunes groups. Topic and queue declarations remain. It includes active work and is not retention maintenance.

Transactions and errors​

Destructive global scope, transactional and unbatched. Can block or invalidate active work; stop relevant applications before a deliberate committed purge. Group pruning can raise 40001 under stronger isolation.

All calls require the applicable caller privileges. See SQL errors for driver failures and uncertain outcomes.

Example​

Run only in an isolated scratch database: this example targets every queue and takes real locks even though it rolls back. Use psql with ON_ERROR_STOP.

BEGIN;
-- Isolated scratch database only: this targets the entire installation.
SELECT postgremq.purge_all_messages();
SELECT * FROM postgremq.get_queue_statistics();
ROLLBACK;

Ordinary delivery counts become zero inside the transaction. Rollback does not make this suitable for probing a busy production database.

Related: Topology, SQL conventions.