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

Sort follow requests, followers, and following by updated_at #774

Merged
merged 2 commits into from
Aug 31, 2022

Conversation

blackle
Copy link
Contributor

@blackle blackle commented Aug 27, 2022

so it is consistent with mastodon and other AP implementations, where the most recent followers are shown first.

@tsmethurst
Copy link
Contributor

To make sure database queries don't get slow, we need to update some indexes to make this work properly, otherwise the new indexes create temp b-trees.

Now:

Screenshot from 2022-08-29 11-16-39

If we change the query without updating indexes:

Screenshot from 2022-08-29 11-16-50

This is the index suggested by sqlite3:

Screenshot from 2022-08-29 11-18-23

So in a migration, these four indexes:

follow_requests_account_id_idx
follow_requests_target_account_id_idx
follows_account_id_idx
follows_target_account_id_idx

need to be dropped and recreated, by adding updated_at desc at the end. For example:

CREATE INDEX "follow_requests_account_id_idx" ON "follow_requests" (
	"account_id",
	"updated_at"	DESC
)

Once that's done, this should be good to go :) But I think I'd rather get 0.4.0 out before adding another migration, so take your time.

@blackle blackle force-pushed the sort-follows-by-updated branch from 979ab81 to adbc166 Compare August 30, 2022 02:06
@blackle
Copy link
Contributor Author

blackle commented Aug 30, 2022

added the migration. explain query plan seems not to use a temporary b-tree anymore!

@tsmethurst tsmethurst merged commit daec9ab into superseriousbusiness:main Aug 31, 2022
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