Cleaning Up the Mail Queue in Oracle APEX
🚨 WARNING: DO NOT RUN THIS IN PRODUCTION!
Before executing any cleanup operations, ensure you are working in a development or test environment. Deleting the APEX mail queue in a production system can lead to data loss and disrupt email notifications.
📌 Introduction
Oracle APEX includes an internal mail queue for managing outbound emails. Over time, this queue can accumulate unwanted records, leading to delays in email processing and increased storage usage. This guide explains how to safely clean up the APEX mail queue while considering different execution privileges.
🔹 Why Clean Up the APEX Mail Queue?
✅ Fix stuck emails that are failing to send
✅ Free up storage space occupied by unnecessary emails
✅ Improve performance by reducing queue processing overhead
✅ Reset the mail queue after testing email functionalities
🔹 How to Check the Existing Mail Queue
Before deleting emails, check the existing records in the queue:
📌 If this query returns too many records, it's a good indication that cleanup is needed.
🔹 Cleaning Up the APEX Mail Queue
The following PL/SQL block deletes all queued emails for all workspaces.
🔍 Breakdown of the Script
- Iterates through all APEX workspaces
- Sets the correct workspace ID to ensure deletion occurs in the right context
- Deletes all records from the
apex_mail_queue
table - Commits the changes to finalize the deletion
🔹 Verifying the Cleanup
After running the cleanup script, confirm that the mail queue is empty:
If the result is 0
, then the cleanup was successful.
🔹 Additional Cleanup - Removing Stuck Mail Logs
If there are old mail log entries taking up space, you may also want to clean them up:
🚀 Best Practices
✅ Run cleanup in non-production environments only
✅ Backup APEX before deleting any data
✅ Use scheduled jobs to manage mail queue retention
Post a Comment
Post a Comment