Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

There's a "Jobs" section on my website (custom post type), with various associated taxonomies (language spoken, type of contract, location, etc.) The website also has a very big user base (about 10 000 subscribers). These users have access to a form where they chose "jobs" criterias they are interested in, in order to receive a daily email with the list of "jobs" that correspond to their criterias.

I'd like to have your opinion on the best way to implement that functionality.

My first approach is this :

  1. Loop through all the "subscriber" users
  2. For each user, get the criterias they have chosen (language, type of contract, city, etc.)
  3. with these criterias, make a WP_Query on all the "jobs" published that day
  4. send the results by email

This function would be triggered daily thanks to wp cron.

My worry is that this is perhaps a very ressource intensive way (that's a loop executing 10 000 different wp_queries in a row!) The website is hosted on a dedicated webserver (quad core with about 8Gigs of ram)

Is there a more efficient way ?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Make the user query when the job is submitted and put all matching subscribers in a queue. At the end of the day run through the queue once and send the mails.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.