Replace notes(userId) index with (userId, id) #28
No reviewers
Labels
No labels
bug
customization
duplicate
enhancement
feature parity
help wanted
high priority
invalid
low priority
question
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: woem.men/forkey#28
Loading…
Reference in a new issue
No description provided.
Delete branch "sugar/forkey:replace-notes-user-id-index-with-user-id-id"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
This improves performance of queries searching posts by a given user, optionally with a provided range of
id
s (pagination), and then using ORDER BY to sort posts by date, with a provided limit.Examples of such queries include: viewing posts by a given user, as well as checking when the last post by a given user was written for Mastodon API.
Why
Making Mastodon API more performant, as it will look up the date of most recent post a lot (using index-only scan). Also, this will help with performance of
users/notes
Misskey API.Iceshrimp already did that change before:
2efdbae42e
.Without this index, the database essentially has to fetch all posts by a given user to be able to determine what were the most recent posts.
See https://use-the-index-luke.com/sql/partial-results/top-n-queries.
Additional info (optional)
Checklist
The iceshrimp change also changes another file and adds
@Index("IDX_note_userId_id", ["userId", "id"])
to the top of Note. We have the MiNote class and I assume it would be good to put that there?d1ab9aca8c
to83151ab37d
83151ab37d
to93dba136ab
this unit test is failing:
the translation is:
Folders cannot be recursively structured.
it returns a 200 status code when it should be 400
im a bit unsure whats going on with that failing unit test. its now failing on another pull request even though it wasnt a few minutes ago
alright, i reran the unit tests, and its passing now
opened an issue: #44
Everything here looks good!