[mythtv-users] Converting scripts to not use the database directly

Simon Hobson linux at thehobsons.co.uk
Tue Nov 4 08:12:42 UTC 2014


jedi <jedi at mishnet.org> wrote:

>>> Yes it's a substitute, and probably workable, but from what I'm seeing it looks like a very inferior substitute.
>>> 
>>> It looks like a simple statement :
>>>> update channel set channum=channum+10000 where channum<  1000 and not channum between 700 and 799
>>> becomes a loop where I've got to work through all the channels, perform a test, and update some of them.
>> 
>> And we all know just how long a modern computer takes to loop
>> through hundreds of things (or even a couple thousand for some
> 
>    You're trying to be sarcastic but this is actually the truth.
> 
>    Doing things in the least efficient way that you can possibly think
> of will in fact bog down a modern computer system. You can easily see
> this for yourself and it doesn't take a huge dataset to do it either.

For my use case I don't care about the time - it's a script I only run once or twice after a channel scan. But yes, I've seen "suboptimal" techniques bring systems to a halt - my favourite one from a previous job was a report that took 40 hours to run (and could only be run at weekends as it ground the system to an almost halt) due to inefficient non-use of indexes on a large table. Re-written with a different tool, and taking care of index use, it got down to 90 seconds and could be run any time without users noticing.
But I digress ...

My observation was that we are taking a step back from being able to use a tool where all the looping is nicely handled for us. Instead, everyone who writes a script to operate with the API would, it appears, have to re-invent the wheel every time.

I understand the desire to remove direct access ot the DB, but to remove a "good" tool (from the user's perspective) and replace it with what appears at the moment to be very inferior does seem a step backwards. IMO to be a "good" replacement the API needs to support set operations, arbitrary joins, arbitrary selections, and relative updates - which makes it sound rather like SQL ! It looks very much like at least 1 or 2 of those are missing.



More information about the mythtv-users mailing list