diff --git a/psf-memo-db/specs/feed-query-performance.feature b/psf-memo-db/specs/feed-query-performance.feature index 77639b6..ac373ab 100644 --- a/psf-memo-db/specs/feed-query-performance.feature +++ b/psf-memo-db/specs/feed-query-performance.feature @@ -12,8 +12,9 @@ # reply-count map. # This feature specifies the capped-scan optimization: # - reply counts are computed per returned post (per-page), not globally. -# - the total scan is capped to the last TOTAL_SCAN_CAP top-level posts so -# hasMore still works for the first pages without walking the whole index. +# - the total scan is capped to the last TOTAL_SCAN_CAP (500) top-level posts, +# so corpora smaller than the cap report an exact total while larger corpora +# stay bounded and hasMore still works for the first pages. Feature: Feed query performance Background: @@ -31,12 +32,12 @@ Feature: Feed query performance | 3 | 0 | post-019 | 1 | 3 | | 3 | 0 | post-018 | 0 | 3 | - Scenario Outline: Feed query performance - 2 the total scan is capped + Scenario Outline: Feed query performance - 2 the total is exact when the index is smaller than the scan cap When the client requests /posts/recent with limit and offset Then the response pagination shows total and hasMore And the postHeights store was read at most entries Examples: | limit | offset | total | hasMore | max_entries | - | 3 | 0 | 10 | true | 13 | - | 5 | 0 | 10 | true | 15 | + | 3 | 0 | 21 | true | 24 | + | 5 | 0 | 21 | true | 24 | diff --git a/psf-memo-db/specs/feed-total-cap.feature b/psf-memo-db/specs/feed-total-cap.feature new file mode 100644 index 0000000..6b3e4c5 --- /dev/null +++ b/psf-memo-db/specs/feed-total-cap.feature @@ -0,0 +1,20 @@ +# Scenarios: Feed total cap - 1 +# +# GET /posts/recent caps its total scan at TOTAL_SCAN_CAP (500) eligible +# top-level posts. A corpus larger than the cap reports a total of exactly 500 +# and reads at most offset + limit + 500 postHeights entries. +Feature: Feed total cap + + Background: + Given a psf-memo-db instance with posts, postHeights, addrPostHeights, postChildren, likes, and postLikes stores + Given the fixture "many-top-level-posts" is loaded into the posts and likes stores + + Scenario Outline: Feed total cap - 1 the recent-feed total is capped at 500 + When the client requests /posts/recent with limit and offset + Then the response pagination shows total and hasMore + And the postHeights store was read at most entries + + Examples: + | limit | offset | total | hasMore | max_entries | + | 3 | 0 | 500 | true | 503 | + | 50 | 499 | 500 | false | 510 |