diff options
author | Kaushik Lingarkar <kaushik.lingarkar@linaro.org> | 2022-09-02 14:28:17 -0700 |
---|---|---|
committer | Kaushik Lingarkar <kaushik.lingarkar@linaro.org> | 2022-09-07 14:34:24 +0000 |
commit | c992eff8e5f0822f629826e2093425880c4fe16c (patch) | |
tree | 3e3d084b9e945f141da1296bda5cb903421064fe | |
parent | f84e5180fc32210db3d85a75d088f5ce841e5c68 (diff) |
Avoid fetching more results than needed in paginated index queries
The 'limit' when paginating the source already has 'start' added
to it when query options are converted for index backend. We already
have tests ensuring it. Adding it again to 'limit' will fetch us
more results than we need. These extra results will eventually be
trimmed, but we end-up doing more work than needed.
On a test site with ~25k open changes, query-limit of 50 and ES as
index backend a query like [1], when run with a user (who can't see
most changes) now does 3 index searches and finishes in ~200ms with
this change as opposed to 4 and ~250ms without it. Note that, this
stat also depends on the fact the visible and non-visible changes
are intertwined together.
[1] gerrit query 'status:open' --start 40
Release-Notes: skip
Change-Id: I99bc17d059b06ec0a904cb0c4036ab2ec2f45d23
-rw-r--r-- | java/com/google/gerrit/index/query/AndSource.java | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/java/com/google/gerrit/index/query/AndSource.java b/java/com/google/gerrit/index/query/AndSource.java index c99e60ae5a..58b49cf76b 100644 --- a/java/com/google/gerrit/index/query/AndSource.java +++ b/java/com/google/gerrit/index/query/AndSource.java @@ -119,7 +119,7 @@ public class AndSource<T> extends AndPredicate<T> final int limit = p.getOptions().limit(); Object searchAfter = resultSet.searchAfter(); int pageSize = limit; - while (skipped && r.size() < limit + start) { + while (skipped && r.size() < limit) { skipped = false; pageSize = getNextPageSize(pageSize); ResultSet<T> next = |