discourse/app/jobs
David Taylor 93c33e02f0
PERF: Avoid full `posts` table scans during anonymisation (#21081)
2e78045a fixed the anonymization job so that it correctly updated self-mentions, which are not logged in the post_actions table. The solution was to scan the entire `posts` table with an `raw ILIKE` query. On sites with many posts, this can take a very long time.

This commit updates the job to take a two-pass approach:

First, we update posts based on the post_actions table. This is much more efficient than a full table scan, and takes care of all 'non-self' mentions.

Then, we make a second pass using the `raw ILIKE` approach. Since we already took care of most posts, we can scope this down to self-mentions only. By filtering the query to a specific posts.user_id, it is significantly more performant than a full table scan.
2023-04-12 18:39:10 +01:00
..
concerns DEV: Apply syntax_tree formatting to `app/*` 2023-01-09 14:14:59 +00:00
onceoff DEV: Prefer \A and \z over ^ and $ in regexes (#19936) 2023-01-20 12:52:49 -06:00
regular PERF: Avoid full `posts` table scans during anonymisation (#21081) 2023-04-12 18:39:10 +01:00
scheduled FEATURE: Move bootstrap mode indicator to header (#20663) 2023-03-24 15:59:03 +02:00
base.rb DEV: Prefer \A and \z over ^ and $ in regexes (#19936) 2023-01-20 12:52:49 -06:00