From a6a7bbed0954eec317b9fc8edb7f8bc2f3f18fd3 Mon Sep 17 00:00:00 2001
From: Karl Dietz <dekarl@users.sourceforge.net>
Date: Sun, 15 Jul 2012 14:44:10 +0200
Subject: [PATCH 7/7] Speed up and reduce temporary space of time search a lot.
By factoring out the description into a super query the performance can
be greatly improved (e.g. from 2 minutes to 2 seconds)
Thanks to sphery for inspiration by [d9fb21853f] and justinh for testing
and fixing my braino with the column order.
Closes #10023
---
mythtv/libs/libmyth/programinfo.cpp | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/mythtv/libs/libmyth/programinfo.cpp b/mythtv/libs/libmyth/programinfo.cpp
index 3bf35ea..972b951 100644
a
|
b
|
static bool FromProgramQuery( |
4530 | 4530 | const QString &sql, const MSqlBindings &bindings, MSqlQuery &query) |
4531 | 4531 | { |
4532 | 4532 | QString querystr = QString( |
| 4533 | "SELECT program.description, sub.* FROM program, (" |
4533 | 4534 | "SELECT DISTINCT program.chanid, program.starttime, program.endtime, " |
4534 | | " program.title, program.subtitle, program.description, " |
| 4535 | " program.title, program.subtitle, " |
4535 | 4536 | " program.category, channel.channum, channel.callsign, " |
4536 | 4537 | " channel.name, program.previouslyshown, channel.commmethod, " |
4537 | 4538 | " channel.outputfilters, program.seriesid, program.programid, " |
… |
… |
static bool FromProgramQuery( |
4565 | 4566 | if (!sql.contains(" LIMIT ")) |
4566 | 4567 | querystr += " LIMIT 20000 "; |
4567 | 4568 | |
| 4569 | querystr += " ) AS sub WHERE program.chanid=sub.chanid AND program.starttime=sub.starttime"; |
4568 | 4570 | query.prepare(querystr); |
4569 | 4571 | MSqlBindings::const_iterator it; |
4570 | 4572 | for (it = bindings.begin(); it != bindings.end(); ++it) |
… |
… |
bool LoadFromProgram( |
4597 | 4599 | { |
4598 | 4600 | destination.push_back( |
4599 | 4601 | new ProgramInfo( |
4600 | | query.value(3).toString(), // title |
4601 | | query.value(4).toString(), // subtitle |
4602 | | query.value(5).toString(), // description |
| 4602 | query.value(4).toString(), // title |
| 4603 | query.value(5).toString(), // subtitle |
| 4604 | query.value(0).toString(), // description |
4603 | 4605 | query.value(6).toString(), // category |
4604 | 4606 | |
4605 | | query.value(0).toUInt(), // chanid |
| 4607 | query.value(1).toUInt(), // chanid |
4606 | 4608 | query.value(7).toString(), // channum |
4607 | 4609 | query.value(8).toString(), // chansign |
4608 | 4610 | query.value(9).toString(), // channame |
4609 | 4611 | query.value(12).toString(), // chanplaybackfilters |
4610 | 4612 | |
4611 | | MythDate::as_utc(query.value(1).toDateTime()), // startts |
4612 | | MythDate::as_utc(query.value(2).toDateTime()), // endts |
4613 | | MythDate::as_utc(query.value(1).toDateTime()), // recstartts |
4614 | | MythDate::as_utc(query.value(2).toDateTime()), // recendts |
| 4613 | MythDate::as_utc(query.value(2).toDateTime()), // startts |
| 4614 | MythDate::as_utc(query.value(3).toDateTime()), // endts |
| 4615 | MythDate::as_utc(query.value(2).toDateTime()), // recstartts |
| 4616 | MythDate::as_utc(query.value(3).toDateTime()), // recendts |
4615 | 4617 | |
4616 | 4618 | query.value(13).toString(), // seriesid |
4617 | 4619 | query.value(14).toString(), // programid |