if the search is for one tag, then 'count(tag)' (expensive function) = 'tag.count' (index lookup)

This commit is contained in:
Shish 2010-02-02 16:33:56 +00:00
parent e96e350ccb
commit 3b2941a5bc

View file

@ -140,6 +140,11 @@ class Image {
} }
return $total; 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 { else {
$querylet = Image::build_search_querylet($tags); $querylet = Image::build_search_querylet($tags);
$result = $database->execute($querylet->sql, $querylet->variables); $result = $database->execute($querylet->sql, $querylet->variables);