Skip to content

Improve IP cleanup query#11871

Merged
Gargron merged 1 commit intomastodon:masterfrom
abcang:improve_ip_cleanup
Sep 17, 2019
Merged

Improve IP cleanup query#11871
Gargron merged 1 commit intomastodon:masterfrom
abcang:improve_ip_cleanup

Conversation

@abcang
Copy link
Copy Markdown
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.

2 participants