Skip to content

perf: hydrate user feed pages with one article_tags pass - #1262

Open
devin-ai-integration[bot] wants to merge 1 commit into
devin/task-25-feed-order-paginationfrom
devin/task-22-feed-tag-hydration
Open

devin-ai-integration[bot] wants to merge 1 commit into
devin/task-25-feed-order-paginationfrom
devin/task-22-feed-tag-hydration

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Summary

Stacked on #1259. The user feed spent most of its time hydrating the 20-article page: SQLite joined article_tags (no index on article_id) once per selected article. findArticlesOfAuthors and findArticlesOfAuthorsWithCursor now page article ids into a CTE FA and read the page's tag rows in one pass:

with FA as (select id from articles where user_id in (...) order by created_at desc limit ?, ?)
select ... from articles A
left join (select rowid tagSeq, article_id, tag_id from article_tags
           where article_id in (select id from FA) order by rowid limit -1) AT on A.id = AT.article_id
...
where A.id in (select id from FA)
order by A.created_at desc, AT.tagSeq

AT.tagSeq (the article_tags rowid) pins tagList to the order the current plan already returns, so responses are unchanged. No schema or index changes. Uses SQLite's rowid, like the rest of the app this mapper is SQLite-only.

Numbers

Seed: 200 users, 10,000 articles, 50 tags, 19,964 article tags, 20,000 favorites, 4,000 follows. 200 sequential requests per endpoint after 30 warmup, as a user following 20 authors. Run on #1258 + #1259 merged (Java 21 / Boot 3.5).

Endpoint master p50 / p95 #1258+#1259 p50 / p95 + this PR p50 / p95
GET /articles 127.7 / 139.1 ms 117.0 / 127.9 ms 116.7 / 123.4 ms (unchanged path)
GET /articles/feed 20.7 / 21.6 ms 23.9 / 40.0 ms 11.9 / 12.8 ms
GraphQL feed(first: 20) 25.2 / 33.0 ms 26.0 / 29.2 ms 15.7 / 18.0 ms

Verification

  • Response parity: 26 REST and GraphQL responses (feed pages at several offsets, forward and backward cursor pages, article lists, single articles, anonymous and signed in) are byte-identical before and after.
  • spotlessCheck test: 70/70 green on this branch (Java 11) and merged onto Upgrade to Java 21 / Spring Boot 3.5 (revives #1185) #1258 (Java 21).

Seen while benchmarking, not changed here: /articles/feed with an offset past the end returns 500 (empty in () in ArticleFavoritesReadService.articlesFavoriteCount), before and after this PR; GraphQL feed still runs 46 SQL statements per request because Article.author is resolved per article.


Latency Optimizer opened this PR for Matthew
Implemented in session Benchmark RealWorld feed on Java 21 stack
Review with Devin · Open in Devin Desktop


@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Custom reviewers

  • 🧪 Test 2 reviewer: no findings · View
  • 🚩 TD Enterprise Architecture: no findings · View
  • 👁️ TD Information Security: no findings · View
  • 🧠 TD French Language (Bill 96): no findings · View
  • ⏱️ TD API Contracts: no findings · View

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants