You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DELETEFROM"tasks"WHERE"tasks"."id"IN (SELECT"tasks"."id"FROM"tasks"WHERE (end_at <'2023-05-13 08:28:12.447024') ORDER BY"tasks"."end_at"ASCLIMIT500)
For big tables sorting by custom field could cause:
ActiveRecord::QueryCanceled: PG::QueryCanceled: ERROR: canceling statement due to statement timeout
So, I think it's better to rewrite the something like:
def call(collection)
while true
keys = collection.limit(batch_size).pluck(collection.primary_key)
break if keys.blank?
collection.where(collection.primary_key => keys).delete_all
end
end
The text was updated successfully, but these errors were encountered:
@smily-ivan Are you sure that this is caused by ORDER and not WHERE statement? ordering by whatever you have in filters is the most optimal solution here, so it looks like the issue is not caused by ordering statement but rather a lack of index
This strategy generates following SQL query:
For big tables sorting by custom field could cause:
ActiveRecord::QueryCanceled: PG::QueryCanceled: ERROR: canceling statement due to statement timeout
So, I think it's better to rewrite the something like:
The text was updated successfully, but these errors were encountered: