mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Add multicolumn indexes on votes and notifications tables
To put a long story short, when we do joins on these tables in our pkg_search_page() function, we always join on both the user ID and package ID columns. By creating multicolumn indices, we can always get the exact row we are looking for in the table. The benefits of adding a unique index should also speak for themselves, as we previously did not have this on either of these tables. This is part one of a two-part series to address the fact that this query was often showing up in our slow query logs. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Loui Chang <louipc.ist@gmail.com>
This commit is contained in:
parent
135d610957
commit
e2b3bd1c37
1 changed files with 2 additions and 1 deletions
|
@ -168,7 +168,7 @@ CREATE TABLE PackageVotes (
|
|||
FOREIGN KEY (UsersID) REFERENCES Users(ID) ON DELETE CASCADE,
|
||||
FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX VoteUsersIDPackageID ON PackageVotes (UsersID, PackageID);
|
||||
|
||||
-- The individual files and their file system location.
|
||||
--
|
||||
|
@ -206,6 +206,7 @@ CREATE TABLE CommentNotify (
|
|||
FOREIGN KEY (PkgID) REFERENCES Packages(ID) ON DELETE CASCADE,
|
||||
FOREIGN KEY (UserID) REFERENCES Users(ID) ON DELETE CASCADE
|
||||
);
|
||||
CREATE UNIQUE INDEX NotifyUserIDPkgID ON CommentNotify (UserID, PkgID);
|
||||
|
||||
-- Vote information
|
||||
--
|
||||
|
|
Loading…
Add table
Reference in a new issue