Optimize queries for open/merged changes by project + branch
When searching changes by project name and branch name the database query only filters the changes by project. The filtering by branch is only done afterwards in the code. If there is a big difference between branches the search might become expensive since many roundtrips with the database may be needed until the changes for the specified branch are found (because the result of each database query is limited to the number of entries that can be shown on the result screen). Change-Id: I7d0aede1db4ff716049af24a8c2fb1af99278d34 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -101,6 +101,16 @@ public interface ChangeAccess extends Access<Change, Change.Id> {
|
||||
ResultSet<Change> allClosedNext(char status, String sortKey, int limit)
|
||||
throws OrmException;
|
||||
|
||||
@Query("WHERE open = false AND status = ? AND dest = ? AND sortKey > ?"
|
||||
+ " ORDER BY sortKey LIMIT ?")
|
||||
ResultSet<Change> byBranchClosedPrev(char status, Branch.NameKey p,
|
||||
String sortKey, int limit) throws OrmException;
|
||||
|
||||
@Query("WHERE open = false AND status = ? AND dest = ? AND sortKey < ?"
|
||||
+ " ORDER BY sortKey DESC LIMIT ?")
|
||||
ResultSet<Change> byBranchClosedNext(char status, Branch.NameKey p,
|
||||
String sortKey, int limit) throws OrmException;
|
||||
|
||||
@Query
|
||||
ResultSet<Change> all() throws OrmException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user