python - Best practices for monitoring database dependent events -


what best method/approach creating python script dependent on information in database. example:

data being added db. if standard deviation based on column "a" goes above 1, 1.5 or 2, based on user preferences notified. if user has setting set @ 1.5 notified if st.dev above 1.5.

pushing info user not in question, how optimally monitor database updates is.

so far thought of 3 ways:

  1. triggers in mysql, problem here not want leave calculations in mysql. not efficient solution, imagine
  2. create script , run crontab queries data , checks parameters , against user preferences.
  3. creating artificial crontab while true: , sleep combination

any other more optimal or out of box solution missing?

i have not done in mysql, triggers plenty optimized in oracle things. expect mysql similar. if require running calculation every update, trigger fastest method, , guaranteed method date.

i suppose if used external script, run every few minutes? going faster running trigger on every update nature, mysql has time based triggers http://dev.mysql.com/doc/refman/5.1/en/events.html

with trigger, compiled sql trigger stay in database instance's memory likely. compiled sql plenty fast.

i think it's cleaner have sort of thing done triggers, rather maintaining external scripts. opinion though.

if data large mess around moving average formulas, , possibly reduce total number of calculations. seems possible, don't have math background that.

in summary, easy throw sample table , test trigger. give try, think you'll find suites performance needs. if doesn't i'de interested in seeing results.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -