Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize timeline for limit=1 #1971

Merged
merged 2 commits into from
Dec 15, 2023
Merged

Optimize timeline for limit=1 #1971

merged 2 commits into from
Dec 15, 2023

Conversation

devinivy
Copy link
Collaborator

On getTimeline, the limit=1 case is used commonly to check if there are new items at the top of the timeline. Since it's so common, this is a shot at optimizing it. The most common strategy that postgres takes to build a timeline is to grab all recent content from each of the user's follow, then paginate it. The downside here is that it requires grabbing all recent content from all follows, even if you only want a single result. The approach here instead takes the single most recent post from each of the user's follows, then sorts only those and takes the top item.

Copy link
Collaborator

@dholms dholms left a comment

Choose a reason for hiding this comment

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

excellent 👌

@devinivy devinivy merged commit 80161e3 into main Dec 15, 2023
11 checks passed
@devinivy devinivy deleted the timeline-limit-1-opt branch December 15, 2023 20:45
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.

2 participants