[epiphany/history-rewrite-second: 25/26] history-service: do not join urls and visits table unnecessarily
- From: Claudio Saavedra <csaavedra src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/history-rewrite-second: 25/26] history-service: do not join urls and visits table unnecessarily
- Date: Fri, 27 Jan 2012 12:12:00 +0000 (UTC)
commit 8ec361c44d10c5a14266b38b6fe7d72cab466ff6
Author: Claudio Saavedra <csaavedra igalia com>
Date: Wed Jan 11 14:59:57 2012 +0200
history-service: do not join urls and visits table unnecessarily
If there is no visit time range there is no need to perform a inner
join between these two tables, so spare the hassle.
lib/history/ephy-history-service-urls-table.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/lib/history/ephy-history-service-urls-table.c b/lib/history/ephy-history-service-urls-table.c
index c11713b..de0d516 100644
--- a/lib/history/ephy-history-service-urls-table.c
+++ b/lib/history/ephy-history-service-urls-table.c
@@ -238,8 +238,7 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery *
"urls.zoom_level, "
"urls.host "
"FROM "
- "urls JOIN visits ON visits.url = urls.id "
- "WHERE ";
+ "urls ";
int i = 0;
@@ -248,10 +247,15 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery *
statement_str = g_string_new (base_statement);
- if (query->from > 0)
- statement_str = g_string_append (statement_str, "visits.visit_time >= ? AND ");
- if (query->to > 0)
- statement_str = g_string_append (statement_str, "visits.visit_time <= ? AND ");
+ if (query->from > 0 || query->to > 0) {
+ statement_str = g_string_append (statement_str, "JOIN visits ON visits.url = urls.id WHERE ");
+ if (query->from > 0)
+ statement_str = g_string_append (statement_str, "visits.visit_time >= ? AND ");
+ if (query->to > 0)
+ statement_str = g_string_append (statement_str, "visits.visit_time <= ? AND ");
+ } else {
+ statement_str = g_string_append (statement_str, "WHERE ");
+ }
for (substring = query->substring_list; substring != NULL; substring = substring->next)
statement_str = g_string_append (statement_str, "(urls.url LIKE ? OR urls.title LIKE ?) AND ");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]