[mythtv] SELECT where RecordChanged... once a second

Kirby Vandivort kvandivo at ks.uiuc.edu
Fri Aug 29 15:46:27 EDT 2003

> > Come to find out,
> >
> > SELECT data FROM settings WHERE value = "RecordChanged"
> >
> > is getting called once a second, every second..
> >
> > So, this was chewing up 92 bytes/line of the log file, 3600 times a
> > hour, 24 hours a day..  (close to 8 megs of logs a day)
> >
> > I've since reworked the mysql logging parameters a bit to remove my
> > problem with it..
> >
> > This was indirectly mentioned back in April..
> >
> > http://www.gossamer-threads.com/perl/mailarc/gforum.cgi?post=56963
> >
> > Since we can assume that the finest granularity of programming is
> > on the minute, is it really necessary to check every second?
> >
> > >From looking in scheduler.cpp, it looks like a sleep(1) is being
> > done at the end of the while(1) and the db call is (eventually)
> > getting done inside of that while.  There are a number of things
> > going on inside the loop; some of which need a granularity of 1
> > second..  I wonder if the SELECT could be pulled out of that..
> >
> > I'm just thinking out loud.  I might look into doing something about
> > the frequency of that at some point if I get a chance if people see it
> > as a useful thing.
> Well, if you schedule a recording for a program that's already started, you
> don't want to wait a minute before the backend picks it up.

True....  Hmmm...

Realistically, I'd hypothesize that, on average, 'record' actually 
changes slightly more than once per day (assuming you have your cron
set up to grab new data once a day).  Definitely the primary time
it would change is when you get new data, and the only other times
would be when a user actually modified their record list..  Which,
in reality really doesn't happen all that often.. (more when you
are first starting with myth, of course  :)

So, we have an event that is occuring, let's say twice or three times
a day on average, and we are checking for it 86,400 times.

Again, I'm just thinking out loud here..  What if we had 6543 listening
for a command to recheck 'record'?  Then, when something actually changed
the record table it would ping 6543 with a note saying that it had done
it.. (a poor man's callback, if you will)

Another suggestion for those of you running mysql 4+..  Turn on caching.
It can effectively prevent disk hits for those selects..  Add something

# set the cache to 8 megs
query_cache_size = 8M
query_cache_type = 1

to your [mysqld] section of my.cnf.


Kirby Vandivort                      Theoretical and Computational Biophysics 
Email: kvandivo at ks.uiuc.edu          3051 Beckman Institute
http://www.ks.uiuc.edu/~kvandivo/    University of Illinois
Phone: (217) 244-5711                405 N. Mathews Ave
Fax  : (217) 244-6078                Urbana, IL  61801, USA

More information about the mythtv-dev mailing list