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
Rails change_column_null method accepts four arguments, with the fourth one replacing existing NULLs with some other value. Looks kinda useful feature although the implementation of such a replacement might be pretty dangerous on large tables (postgres, mysql):
UPDATE#{quote_table_name(table_name)}SET#{quote_column_name(column_name)}=#{quote_default_expression(default, column)}WHERE#{quote_column_name(column_name)} IS NULL
What we're doing here is a WHERE query on a table which might be lacking of needed index on column_name and UPDATE for (potentially) millions of records at once.
A little more safe way might be to require user to make this UPDATE in batches manually before firing change_column_null up.
WDYT?
The text was updated successfully, but these errors were encountered:
Rails change_column_null method accepts four arguments, with the fourth one replacing existing NULLs with some other value. Looks kinda useful feature although the implementation of such a replacement might be pretty dangerous on large tables (postgres, mysql):
What we're doing here is a
WHERE
query on a table which might be lacking of needed index oncolumn_name
andUPDATE
for (potentially) millions of records at once.A little more safe way might be to require user to make this
UPDATE
in batches manually before firingchange_column_null
up.WDYT?
The text was updated successfully, but these errors were encountered: