mirror of https://github.com/zulip/zulip.git
3a825ef22c
This management command creates the same indexes as migrations 82, 83, and 95, which are all indexes on the huge UserMessage table. (*) This command quickly no-ops with clear messaging when the indexes already exist, so it's idempotent in that regard. (If somebody somehow creates an index by the same name incorrectly, they can always drop it in dbshell and re-run this command.) If any of the migrations have not been run, which we detect simply by the existence of the indexes, then we create them using a `CREATE INDEX CONCURRENTLY` command. This functionality in postgres allows you to create indexes against large tables without disrupting queries against those tables. The tradeoff here is that creating indexes concurrently takes significantly longer than doing them non-concurrently. Since most tables are small, we typically just use regular Django migrations and run them during a brief interval while the app is down. For indexes on big tables, we will want to run this command as part of the upgrade process, and we will want to run it while the app is still up, otherwise it's pointless. All the code in create_indexes() is literally copy/pasted from the relevant migrations, and that scheme should work going forward. (It uses a different implementation of create_index_if_not_exist than the migrations use, but the code is identical lexically in the function.) If we ever do major restructuring of our large tables, such as UserMessage, and we end up droppping some of these indexes, then we will need to make this command migrations-aware. For now it's safe to assume that indexes are generally additive in nature, and the sooner we create them during the upgrade process, the better. (*) UserMessage is huge for large installations, of course. |
||
---|---|---|
.. | ||
__init__.py | ||
add_users_to_mailing_list.py | ||
add_users_to_streams.py | ||
bankrupt_users.py | ||
bulk_change_user_name.py | ||
change_user_email.py | ||
check_apns_tokens.py | ||
check_redis.py | ||
checkconfig.py | ||
compilemessages.py | ||
convert_bot_to_outgoing_webhook.py | ||
create_large_indexes.py | ||
create_stream.py | ||
create_user.py | ||
deactivate_realm.py | ||
deactivate_user.py | ||
delete_old_unclaimed_attachments.py | ||
deliver_email.py | ||
dump_messages.py | ||
email_mirror.py | ||
enqueue_digest_emails.py | ||
enqueue_file.py | ||
export.py | ||
export_single_user.py | ||
export_usermessage_batch.py | ||
fill_memcached_caches.py | ||
generate_invite_links.py | ||
generate_realm_creation_link.py | ||
get_migration_status.py | ||
import.py | ||
initialize_voyager_db.py | ||
knight.py | ||
list_realms.py | ||
logout_all_users.py | ||
makemessages.py | ||
merge_streams.py | ||
print_email_delivery_backlog.py | ||
process_queue.py | ||
purge_queue.py | ||
query_ldap.py | ||
rate_limit.py | ||
reactivate_realm.py | ||
realm_domain.py | ||
realm_emoji.py | ||
realm_filters.py | ||
remove_users_from_stream.py | ||
rename_stream.py | ||
runtornado.py | ||
send_password_reset_email.py | ||
send_stats.py | ||
send_test_email.py | ||
send_webhook_fixture_message.py | ||
set_default_streams.py | ||
set_message_flags.py | ||
show_admins.py | ||
show_unreads.py | ||
soft_activate_deactivate_users.py | ||
sync_ldap_user_data.py | ||
turn_off_digests.py |