Millions of mails are inserted into a MySQL table "EmailQueue" with following fields,
- id - BigInt(20)
- email_address - Varchar(300)
- message - text
- status - enum('Pending','Prioritized','Processing','Processed')
- created_datetime - datetime
- sent_datetime - datetime
Generally the rows will be inserted with 'Pending' status but some high priority mails such as Forget/Reset password will be inserted with 'Prioritized' in status column.
The cron job will run every hour and send the mails as a loop with the batch of 20000 mails in every loop until it finish sending all the emails. Now I want to send the prioritized mails first which can be add to the email queue even when the cron job is running.
What is the best approach to achieve this? I'm not sure if stackoverflow is the place to ask this question, but not sure about a better place. Thanks for any help in advance.