#AlterUniqueTogether performance

4 messages · Page 1 of 1 (latest)

mild oyster
#

I renamed the name of a model field. I have about 10 million rows in the Postgres table for this model. This field is part of a unique_together constraint, so my migration includes a AlterUniqueTogether.

I'm wondering -- what are the performance implications of this? Will it delete the existing PG index and create a new one, or simply rename the existing index?

cunning mesa
#

You can use python manage.py sqlmigrate <app> <migration number> to view the SQL that will be executed for a migration.

#

The rename operation will likely lock the table while it completes. The unique constraint change should lock the table for inserts and updates until it's validated the table.

#

Looks like renaming shouldn't lock anything, I was wrong.