[Fixed]-Add db_index = True to a Django model which already has a lot of data

1👍

Ideally, yes. This would create an index in you sql table. So whenever you run your migrations your table would have added the index.

If you want to try hardcoding it you can in your migration script by adding it in your forward method. It would probably look something like this

db.execute("CREATE INDEX my_index on table_name(col_name)", params=[])

Leave a comment