[mythtv] Slow MythMusic (and likely other slow list building) problem solved

Joseph A. Caputo jcaputo1 at comcast.net
Tue Mar 2 13:27:14 EST 2004

On Tuesday 02 March 2004 12:39, Ed Benckert wrote:
> The second issue is that GetSettings is broken. It asks MySQL EVERY
> time it's called. Thats totally unnecessary. I'm positive it likely
> slows the shit out of MythTv in every module that uses it... if
> MythMusic calls it unnecessarily 7200 times, then I'm sure MythTv
> does it somehow also. How it SHOULD work is there should be an
> internal array/tree/whatever kept in memory with all the settings in
> it. When SaveSetting is called to update the setting in the DB, that
> setting in the array should be cleared out. When GetSetting is called
> again, if the entry in the array is empty, get it from the database,
> otherwise, just return whats in the array. That I'll work on later
> though...

It's not broken, it's by design.  Keep in mind that Myth is not a 
monolithic program.  There are at least 2 executables (mythbackend/
mythfrontend), and multiple instances may be running on multiple 
machines.  The idea is that when Myth needs to query a setting from the 
database, it does so each time it needs it in case some other process 
(another frontend, backend, manual DB edit, etc) has changed the 
setting since the last time it ran.

If, for a particular piece of code, it's only necessary to read the 
value once, then that piece of code should be designed with that in 
mind.  Changing MythContext::Get[Num]Setting isn't the right answer.

So, if mythmusic only needs to call GetNumSetting once instead of every 
time true, change the mythmusic code, not Get[Num]Setting.


More information about the mythtv-dev mailing list