mirror of https://github.com/zulip/zulip.git
1d3f5a0368
This commit updates `0455_set_default_for_can_mention_group` migration to be more efficient when running for a large number of UserGroup objects. Previously, we did a loop over all UserGroup objects and then did a `bulk_update`. All this happened in a single transaction and the transaction was being hold for unacceptably long time for a server with large number of user groups. Also the SQL generated by Django for `bulk_update` took almost quadratic time to evaluate, as the SQL had linear length "CASE" statement which was being resolved for each row. We instead now use ".update" so that we can write the migration without using loop and update the objects in batches of size 1000 so that we do not hold a transaction for very long time. This also helps in avoiding the inefficient SQL that was being executed due to using `bulk_update`. We also update the queries to exclude the groups that already have `can_mention_group` set to a non-null value, as this will help in migration completing quickly when running it more than once. |
||
---|---|---|
.. | ||
actions | ||
data_import | ||
integration_fixtures/nagios | ||
lib | ||
management | ||
migrations | ||
openapi | ||
tests | ||
tornado | ||
transaction_tests | ||
views | ||
webhooks | ||
worker | ||
__init__.py | ||
apps.py | ||
context_processors.py | ||
decorator.py | ||
filters.py | ||
forms.py | ||
logging_handlers.py | ||
middleware.py | ||
models.py | ||
signals.py |