aboutsummaryrefslogtreecommitdiffstats
path: root/lib/history
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2012-01-11 20:59:57 +0800
committerXan Lopez <xan@igalia.com>2012-03-07 04:49:44 +0800
commit54e7023ac883f7eb1f714eaacd28c5766eb25c66 (patch)
tree9e65fe7ec4b7ec8273c62e8269081a965c61ac24 /lib/history
parent994807b0751b2771dbbcd5881c78c10d29ba75b7 (diff)
downloadgsoc2013-epiphany-54e7023ac883f7eb1f714eaacd28c5766eb25c66.tar
gsoc2013-epiphany-54e7023ac883f7eb1f714eaacd28c5766eb25c66.tar.gz
gsoc2013-epiphany-54e7023ac883f7eb1f714eaacd28c5766eb25c66.tar.bz2
gsoc2013-epiphany-54e7023ac883f7eb1f714eaacd28c5766eb25c66.tar.lz
gsoc2013-epiphany-54e7023ac883f7eb1f714eaacd28c5766eb25c66.tar.xz
gsoc2013-epiphany-54e7023ac883f7eb1f714eaacd28c5766eb25c66.tar.zst
gsoc2013-epiphany-54e7023ac883f7eb1f714eaacd28c5766eb25c66.zip
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.
Diffstat (limited to 'lib/history')
-rw-r--r--lib/history/ephy-history-service-urls-table.c16
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 c11713b93..de0d516ac 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 ");