mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-05 14:36:04 +00:00
Do not use WHERE NOT IN in CopyStatusStats migration (#8281)
Fix #8275 As the batch operation progresses, the statuses_stats table grows, and the WHERE NOT IN subquery becomes more expensive
This commit is contained in:
parent
0fc0980de1
commit
f13afa1ee9
|
@ -3,7 +3,7 @@ class CopyStatusStats < ActiveRecord::Migration[5.2]
|
||||||
|
|
||||||
def up
|
def up
|
||||||
safety_assured do
|
safety_assured do
|
||||||
Status.where.not(id: StatusStat.select('status_id')).select('id').find_in_batches do |statuses|
|
Status.unscoped.select('id').find_in_batches(batch_size: 5_000) do |statuses|
|
||||||
execute <<-SQL.squish
|
execute <<-SQL.squish
|
||||||
INSERT INTO status_stats (status_id, reblogs_count, favourites_count, created_at, updated_at)
|
INSERT INTO status_stats (status_id, reblogs_count, favourites_count, created_at, updated_at)
|
||||||
SELECT id, reblogs_count, favourites_count, created_at, updated_at
|
SELECT id, reblogs_count, favourites_count, created_at, updated_at
|
||||||
|
|
Loading…
Reference in a new issue