summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2009-04-11 23:40:58 +0200
committerLoui Chang <louipc.ist@gmail.com>2009-06-18 07:47:17 +0200
commit1ceeda8ab529ba0ba04664621e9edb5f4dfae397 (patch)
tree74a14ac43d64c17a14271fdabb056b634e61f0d6 /web/lib
parente2b3bd1c37d91a747e8f774bbb91aad3dc466c68 (diff)
downloadaur-1ceeda8ab529ba0ba04664621e9edb5f4dfae397.tar.gz
aur-1ceeda8ab529ba0ba04664621e9edb5f4dfae397.tar.xz
Specify explicit joins for package search
Refactor the query to use explicit LEFT JOINs, which appears to be handled by MySQL in a saner fashion than the previous implicit join syntax. This is part two in a slight fixup for observed slow queries in the production environment. With the new indexes and this fixup, a particular iteration of this query will examine only 13346 rows instead of 272060. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Loui Chang <louipc.ist@gmail.com>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/pkgfuncs.inc12
1 files changed, 6 insertions, 6 deletions
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index 056552b9..a4a2dfca 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -437,19 +437,19 @@ function pkg_search_page($SID="") {
Packages.Name, Packages.Version, Packages.Description, Packages.NumVotes,
Packages.ID, Packages.OutOfDate
- FROM PackageCategories, PackageLocations, Packages
+ FROM Packages
LEFT JOIN Users ON (Packages.MaintainerUID = Users.ID) ";
-
if ($SID) {
$q .= "LEFT JOIN PackageVotes
ON (Packages.ID = PackageVotes.PackageID AND PackageVotes.UsersID = $myuid)
LEFT JOIN CommentNotify
ON (Packages.ID = CommentNotify.PkgID AND CommentNotify.UserID = $myuid) ";
}
- $q .= "WHERE
- Packages.CategoryID = PackageCategories.ID
- AND Packages.LocationID = PackageLocations.ID
- AND Packages.DummyPkg = 0 ";
+ $q .= "LEFT JOIN PackageCategories
+ ON (Packages.CategoryID = PackageCategories.ID)
+ LEFT JOIN PackageLocations
+ ON (Packages.LocationID = PackageLocations.ID)
+ WHERE Packages.DummyPkg = 0 ";
// TODO: possibly do string matching on category and
// location to make request variable values more sensible