zulip/zerver/management/commands
Steve Howell 3a825ef22c Add create_large_indexes management command.
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.
2017-08-16 12:38:51 -07:00
..
__init__.py [manual] Rename Django app from zephyr to zerver. 2013-08-06 07:39:36 -04:00
add_users_to_mailing_list.py Replace timezone.now with timezone_now. 2017-04-16 12:28:56 -07:00
add_users_to_streams.py add_users_to_streams: Remove unused imports. 2017-07-08 14:35:42 -07:00
bankrupt_users.py Use do_mark_all_as_read() in bankrupt_users command. 2017-08-04 14:10:46 -07:00
bulk_change_user_name.py bulk_change_user_name: Replace get_user_profile_by_email with get_user. 2017-07-08 14:38:45 -07:00
change_user_email.py management: Add new library for specifying realms. 2017-07-07 13:57:57 -07:00
check_apns_tokens.py Annotate most Zulip management commands. 2016-06-04 10:12:06 -07:00
check_redis.py management: Remove unused import from check_redis command. 2017-08-08 14:13:19 -07:00
checkconfig.py management: Remove unused import from checkconfig command. 2017-08-08 14:13:19 -07:00
compilemessages.py i18n: Fix compilemessages processing extra files in production. 2017-02-03 17:17:23 -08:00
convert_bot_to_outgoing_webhook.py management: Use self.get_user in convert_bot_to_outgoing_webhook. 2017-08-08 14:13:19 -07:00
create_large_indexes.py Add create_large_indexes management command. 2017-08-16 12:38:51 -07:00
create_stream.py management: Use self.get_realm in create_stream. 2017-08-08 14:13:19 -07:00
create_user.py management: Use self.get_realm in create_user. 2017-08-08 14:13:19 -07:00
deactivate_realm.py management: Use self.get_realm in deactivate_realm. 2017-08-08 14:13:19 -07:00
deactivate_user.py deactivate_users: Replace get_user_profile_by_email with get_user. 2017-07-08 14:38:45 -07:00
delete_old_unclaimed_attachments.py Annotate most Zulip management commands. 2016-06-04 10:12:06 -07:00
deliver_email.py management: Remove unused imports from deliver_email command. 2017-08-08 14:13:19 -07:00
dump_messages.py management: Use self.get_realm in dump_messages. 2017-08-08 14:13:19 -07:00
email_mirror.py management: Remove unused imports from email_mirror command. 2017-08-08 14:13:19 -07:00
enqueue_digest_emails.py Replace timezone.now with timezone_now. 2017-04-16 12:28:56 -07:00
enqueue_file.py pep8: Add compliance with rule E261 to enqueue_file.py. 2017-05-07 23:21:50 -07:00
export.py management: Use self.get_realm in export command. 2017-08-08 14:13:19 -07:00
export_single_user.py export_single_user: Replace get_user_profile_by_email with get_user. 2017-07-08 14:38:45 -07:00
export_usermessage_batch.py management: Remove unused imports from export_usermessage_batch. 2017-08-08 14:13:19 -07:00
fill_memcached_caches.py management: Fix recent argument parsing regressions. 2016-10-16 20:36:33 -07:00
generate_invite_links.py confirmation: Liberate get_link_for_object from ConfirmationManager. 2017-07-17 23:18:47 -07:00
generate_realm_creation_link.py generate_realm_creation_link: Fix line-wrapping of help text. 2017-03-04 19:02:01 -08:00
get_migration_status.py pep8: Fix many rule E128 violations. 2016-12-03 13:33:31 -08:00
import.py management: Remove unused imports from import command. 2017-08-08 14:13:19 -07:00
initialize_voyager_db.py management: Use get_system_bot in initialize_voyager_db. 2017-08-08 14:13:19 -07:00
knight.py management: Use self.get_user in knight command. 2017-08-08 14:13:19 -07:00
list_realms.py management: Create list realms command. 2017-08-04 14:25:03 -07:00
logout_all_users.py management: Use self.get_realm in logout_all_users. 2017-08-08 14:13:19 -07:00
makemessages.py management: Remove unused imports from makemessages. 2017-08-08 14:13:19 -07:00
merge_streams.py management: Use self.get_realm in merge_streams. 2017-08-08 14:13:19 -07:00
print_email_delivery_backlog.py management: Remove unused imports from print_email_delivery_backlog. 2017-08-08 14:13:19 -07:00
process_queue.py management: Remove unused imports from process_queue. 2017-08-08 14:13:19 -07:00
purge_queue.py pep8: Fix E301 pep8 violations. 2016-11-29 08:51:44 -08:00
query_ldap.py Annotate most Zulip management commands. 2016-06-04 10:12:06 -07:00
rate_limit.py rate_limiter: Upgrade unblock_user to generic API. 2017-08-02 18:01:39 -07:00
reactivate_realm.py management: Use self.get_realm in reactivate_realm command. 2017-08-08 14:13:19 -07:00
realm_domain.py management: Use self.get_realm in realm_domain. 2017-08-08 14:13:19 -07:00
realm_emoji.py management: Use self.get_realm in realm_emoji. 2017-08-08 14:13:19 -07:00
realm_filters.py management: Use self.get_realm in realm_filters. 2017-08-08 14:13:19 -07:00
remove_users_from_stream.py remove_users_from_stream: Replace get_user_profile_by_email with get_user. 2017-07-08 14:38:45 -07:00
rename_stream.py management: Use self.get_realm in rename_stream. 2017-08-08 14:13:19 -07:00
runtornado.py tornado: Move setup_tornado_rabbitmq to application.py 2017-07-21 09:55:25 +05:00
send_password_reset_email.py emails: Change reset password emails to use to_user_id. 2017-07-16 16:56:39 -07:00
send_stats.py Annotate most Zulip management commands. 2016-06-04 10:12:06 -07:00
send_test_email.py settings: Change all uses of ZULIP_ADMINISTRATOR to FromAddress.SUPPORT. 2017-07-05 15:33:01 -07:00
send_webhook_fixture_message.py mypy: Fix inconsistencies in use of *args/**kwargs. 2017-02-18 18:39:44 -08:00
set_default_streams.py management: Use self.get_realm in set_default_streams. 2017-08-08 14:13:19 -07:00
set_message_flags.py set_message_flags: Replace get_user_profile_by_email with get_user. 2017-07-08 14:40:55 -07:00
show_admins.py Rename models.get_realm_by_string_id to get_realm. 2017-01-04 17:12:23 -08:00
show_unreads.py Optimize show_unreads --fix approach. 2017-08-04 11:04:43 -07:00
soft_activate_deactivate_users.py management: Log number of soft deactivated/reactivated users. 2017-08-15 22:05:19 -07:00
sync_ldap_user_data.py Annotate most Zulip management commands. 2016-06-04 10:12:06 -07:00
turn_off_digests.py turn_off_digests: Replace get_user_profile_by_email with get_user. 2017-07-08 14:38:45 -07:00