Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do the big price comparison services allow to send emails directly if the price of a product meets your targeted price.

They will email you automatically.

Is it a cron job that scans a table, or is it something compounded into the database?

share|improve this question
up vote 1 down vote accepted

Cron jobs would be a possibillity - an other way would be an event based solution.

Whenever a the price for a certain product is changed (there could be other events also, eg. product sold out ...) - there could be a lookup in a table where limitprices for products are stored - when the condition is met - send an email ..

You could realize it within the database (triggers, stored procedures). But as we try to minimize the logic within the database - we do it in the application server ...

share|improve this answer
How would the trigger send the email? In MySQL – Ryan Jun 20 '11 at 5:44

Obviously, different sites may implement the functionality differently.

Most of the time, though, there will be a job that matches the recent price changes against the list of subscribed users. This could be done as part of the loading of a new set of prices but would more often be done asynchronously to the load process. The bigger the site, the more subscriptions, and the more timely the alerts need to be, the more likely that it would be worthwhile to cache both the subscriptions and the recent changes and to implement a custom notification module.

share|improve this answer

Generally, I would stay away from keeping such logic in the database. A cron job is a good option but if you are using a web framework, most likely there will be some sort of infrastructure and helper classes to invoke particular methods/logic at specified times or intervals. Actions triggered by the database pose risks especially when it is something as sensitive as sending an email to valuable customers.

I don't know how full proof you pricing update system is but if you erroneously update pricing in database which then sends emails to customers, they would not be happy to find out that the new Anthony Weiner bobble-head is not really selling for the price specified in the email. :) In that case you need a cool down period after prices are updated.

share|improve this answer

Your Answer


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.