I'm migrating my Postgres database and am attempting to update a string value to a numeric value, like this:
UPDATE table SET column = 1 WHERE LENGTH(column) = 1;
This table contains around 20 million rows, and the update has been taking forever to run. I have an index on LENGTH(column) as well as 4 other indexes on different columns, one of which is a UNIQUE index on 2 columns. There's also a foreign key constraint on this table.
What could I do to speed this query up? If more information is needed, I'd be happy to provide it.
length(column)). However, this could only be determined with EXPLAIN ANALYZE. But this would seem to make it a moot point as it runs the query. Since this is a migration it should be a 1 time event anyway (at least in user acceptance testing and production environments).