<br><br><div><span class="gmail_quote">On 3/4/06, <b class="gmail_sendername">Niels Dybdahl</b> <<a href="mailto:niels@dybdahl.dk">niels@dybdahl.dk</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="direction: ltr;">
<div><font face="Arial" size="2">Hi,</font></div>
<div><font face="Arial" size="2"></font> </div>
<div><font face="Arial" size="2">I have just upgraded two systems to
0.19.</font></div>
<div><font face="Arial" size="2"></font> </div>
<div><font face="Arial" size="2">On one of them MythWeb is slow to show program
listings (not recordings) and I have found out that it does 246 SQL-queries
similar (WHERE clause differs) to the following for each listing
page:</font></div>
<div><font face="Arial" size="2"></font> </div>
<div> SELECT
program.*,<br>
UNIX_TIMESTAMP(program.starttime) AS
starttime_unix,<br>
UNIX_TIMESTAMP( program.endtime) AS
endtime_unix,<br>
CONCAT(repeat('&diams;', program.stars *
'4'),<br>
IF((program.stars * '4' * 10) %
10,<br>
"&frac12;", "")) AS starstring,
<br>
IFNULL(programrating.system, "") AS
rater,<br>
IFNULL(programrating.rating, "") AS
rating,<br>
oldrecorded.recstatus,<br>
channel.channum<br>
FROM
program<br>
LEFT JOIN programrating USING (chanid,
starttime)<br>
LEFT JOIN
oldrecorded<br>
ON oldrecorded.recstatus IN (-3,
11)<br>
AND IF(oldrecorded.programid OR
oldrecorded.seriesid,<br>
oldrecorded.programid =
program.programid<br>
AND oldrecorded.seriesid =
program.seriesid,<br>
oldrecorded.title =
program.title<br>
AND oldrecorded.subtitle =
program.subtitle<br>
AND oldrecorded.description =
program.description<br>
)<br>
LEFT JOIN channel ON program.chanid =
channel.chanid<br>
WHERE program.chanid='1003' AND program.starttime = FROM_UNIXTIME('1141943100')
GROUP BY program.chanid, program.starttime<br></div>
<div><font face="Arial" size="2">The other system is faster to show program listings
and it only executes 29 of these queries for each page, even though it has more
channels (the first has 9 channels, the second around 100).</font></div>
<div><font face="Arial" size="2">So I would like to know what this query does and/or
how I can control its execution.</font></div></div></blockquote><div><br>I have looked into the php-code and it seems that the query above is executed once for each scheduled recording in the database, even if the schedules is so far ahead that they are not going to be shown on the listings page.
<br></div></div><br>So this could be optimized significantly, by limiting it to schedules within the time frame needed for the program listing page.<br><br>Niels Dybdahl<br><br>