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

Improve IP cleanup query #11871

Merged
merged 1 commit into from
Sep 17, 2019
Merged

Improve IP cleanup query #11871

merged 1 commit into from
Sep 17, 2019

Conversation

abcang
Copy link
Contributor

@abcang abcang commented Sep 17, 2019

  • Changed to delete SessionActivation every 1000
  • Do not update users whose last_sign_in_ip is already null
  • Split select and update because update process that changes last_sign_in_ip to null is slow

before

User Update All (4.1ms)  UPDATE "users" SET "last_sign_in_ip" = NULL WHERE (last_sign_in_at < '2018-09-17 03:21:18.721436')

after:

(3.7ms)  SELECT  "users"."id" FROM "users" WHERE (last_sign_in_at < '2018-09-17 03:21:18.721436') AND "users"."last_sign_in_ip" IS NOT NULL ORDER BY "users"."id" ASC LIMIT $1  [["LIMIT", 1000]]
User Update All (20.1ms)  UPDATE "users" SET "last_sign_in_ip" = NULL WHERE (last_sign_in_at < '2018-09-17 03:21:18.721436') AND "users"."last_sign_in_ip" IS NOT NULL AND "users"."id" IN ($1, $2, $3, $4, $5, $6)  [["id", 7], ["id", 8], ["id", 9], ["id", 10], ["id", 13], ["id", 14]]

@Gargron Gargron merged commit c21386c into mastodon:master Sep 17, 2019
@abcang abcang deleted the improve_ip_cleanup branch September 17, 2019 06:46
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
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.

None yet

2 participants