From 3b2941a5bc96f5f5df0e8fdfeecebcb24e3d25ff Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 2 Feb 2010 16:33:56 +0000 Subject: [PATCH] if the search is for one tag, then 'count(tag)' (expensive function) = 'tag.count' (index lookup) --- core/imageboard.pack.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index c19f3908..74d042b1 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -140,6 +140,11 @@ class Image { } return $total; } + else if(count($tags) == 1) { + return $database->db->GetOne( + $database->engine->scoreql_to_sql("SELECT count FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(?)"), + $tags); + } else { $querylet = Image::build_search_querylet($tags); $result = $database->execute($querylet->sql, $querylet->variables);