summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Brachold <vdr07@deltab.de>2011-02-26 06:58:24 +0000
committerAndreas Brachold <vdr07@deltab.de>2011-02-26 06:58:24 +0000
commiteca6900d3210a8e97bfba4dec124287d11284323 (patch)
tree78b140be04a33fb42fd34a54c33b7dfe008dcd08
parentcfe8b1035d1dd5cda6c9ef8e0ea8662be418d542 (diff)
downloadxxv-eca6900d3210a8e97bfba4dec124287d11284323.tar.gz
xxv-eca6900d3210a8e97bfba4dec124287d11284323.tar.bz2
EPG: improve sql-query on single host environment
-rw-r--r--lib/XXV/MODULES/EPG.pm31
1 files changed, 24 insertions, 7 deletions
diff --git a/lib/XXV/MODULES/EPG.pm b/lib/XXV/MODULES/EPG.pm
index e1d99b6..bd5542e 100644
--- a/lib/XXV/MODULES/EPG.pm
+++ b/lib/XXV/MODULES/EPG.pm
@@ -1075,11 +1075,17 @@ INSERT INTO NEXTEPG select
MIN(e.starttime) as nexttime
FROM EPG as e, CHANNELS as c, CHANNELGROUPS as g
WHERE e.channel_id = c.id
- AND e.vid = c.vid
AND c.grp = g.id
+ AND e.starttime > NOW()
+|;
+
+ # Merge epg entries from different hosts, only if more then one host exists (it slow down query)
+ if(scalar @{$self->{svdrp}->list_hosts()} > 1) {
+ $sqltemp .= qq|
+ AND e.vid = c.vid
AND c.vid = g.vid
-AND e.starttime > NOW()
|;
+ }
my $term;
my $grpsql = '';
@@ -1174,11 +1180,16 @@ FROM
WHERE
e.channel_id = c.id
AND n.channel_id = c.id
- AND c.grp = g.id
- AND c.vid = g.vid
AND e.starttime = n.nexttime
|;
+ # Merge epg entries from different hosts, only if more then one host exists (it slow down query)
+ if(scalar @{$self->{svdrp}->list_hosts()} > 1) {
+ $sql .= qq|
+ AND e.vid = c.vid
+ AND c.vid = g.vid
+|;
+ }
$sql .= $grpsql;
$sql .= qq|
@@ -1323,13 +1334,19 @@ SELECT SQL_CACHE
FROM
EPG as e, CHANNELS as c, CHANNELGROUPS as g
WHERE
- e.channel_id = c.id
+ ? BETWEEN UNIX_TIMESTAMP(e.starttime)
+ AND (UNIX_TIMESTAMP(e.starttime) + e.duration)
+ AND e.channel_id = c.id
AND c.grp = g.id
+|;
+
+ # Merge epg entries from different hosts, only if more then one host exists (it slow down query)
+ if(scalar @{$self->{svdrp}->list_hosts()} > 1) {
+ $sql .= qq|
AND e.vid = c.vid
AND c.vid = g.vid
- AND ? BETWEEN UNIX_TIMESTAMP(e.starttime)
- AND (UNIX_TIMESTAMP(e.starttime) + e.duration)
|;
+ }
my $cmod = main::getModule('CHANNELS');
my $cgroups = $cmod->ChannelGroupsArray('name');