[Django Upgrade] [ENG-3998] Migration Clean squash + Update RunSQL Indexes#10028
Merged
mfraezz merged 7 commits intoAug 23, 2022
Merged
Conversation
fa82935 to
c4322af
Compare
RunSQL Indexes
376d48a to
fcff72a
Compare
RunSQL IndexesRunSQL Indexes
51ae779 to
ac1e404
Compare
ac1e404 to
699fc1c
Compare
cslzchen
commented
Aug 23, 2022
Comment on lines
+16
to
+27
| CREATE UNIQUE INDEX one_quickfiles_per_user ON public.osf_abstractnode USING btree (creator_id, type, is_deleted) WHERE (((type)::text = 'osf.quickfilesnode'::text) AND (is_deleted = false)); | ||
| CREATE INDEX osf_abstractnode_collection_pub_del_type_index ON public.osf_abstractnode USING btree (is_public, is_deleted, type) WHERE ((is_public = true) AND (is_deleted = false) AND ((type)::text = 'osf.collection'::text)); | ||
| CREATE INDEX osf_abstractnode_date_modified_ef1e2ad8 ON public.osf_abstractnode USING btree (last_logged); | ||
| CREATE INDEX osf_abstractnode_node_pub_del_type_index ON public.osf_abstractnode USING btree (is_public, is_deleted, type) WHERE ((is_public = true) AND (is_deleted = false) AND ((type)::text = 'osf.node'::text)); | ||
| CREATE INDEX osf_abstractnode_registered_date_index ON public.osf_abstractnode USING btree (registered_date DESC); | ||
| CREATE INDEX osf_abstractnode_registration_pub_del_type_index ON public.osf_abstractnode USING btree (is_public, is_deleted, type) WHERE ((is_public = true) AND (is_deleted = false) AND ((type)::text = 'osf.registration'::text)); | ||
| CREATE INDEX fileversion_date_created_desc ON public.osf_fileversion USING btree (created DESC); | ||
| CREATE INDEX fileversion_metadata_sha_arch_vault_index ON public.osf_fileversion USING btree (((metadata -> 'sha256'::text)), ((metadata -> 'archive'::text)), ((metadata -> 'vault'::text))); | ||
| CREATE INDEX nodelog__node_id_date_desc ON public.osf_nodelog USING btree (node_id, date DESC); | ||
| CREATE INDEX osf_nodelog_should_hide_nid ON public.osf_nodelog USING btree (should_hide, node_id); | ||
| CREATE UNIQUE INDEX osf_noderequest_target_creator_non_accepted ON public.osf_noderequest USING btree (target_id, creator_id) WHERE ((machine_state)::text <> 'accepted'::text); | ||
| CREATE INDEX lowercase_tag_index ON public.osf_tag USING btree (lower((name)::text), system); |
Collaborator
Author
There was a problem hiding this comment.
More on indexes update
Indexes Comparision
- On
prodserver, there are 922 indexes- See pg_indexes_prod
- In
localenv ondevelop, there are 944 - 21 (silk) = 923 indexes - In
localenv onfeature/django_upgrade, there are 945 - 21 (silk) = 924 indexes - In
localevn onfeature/clean_squash(this PR), there are 933 - 21 (silk) + 12 (new indexes added)= 924 indexes
Comments
First, we've verified the extra index between local-develop and prod is an existing "bug". This is trivial and can be neglected for now.
InstitutioninheritsLoggable, but that 0069 migration didn't actually run, any my script didn't manually create the index here
osf_institution
osf_institution_last_logged_9ac963e2
CREATE INDEX osf_institution_last_logged_9ac963e2 ON public.osf_institution USING btree (last_logged)
Second, the one extra index is not introduced by the squash but by one of our post-migrate signal PRs. This probably doesn't matter though we no longer use expires. There maybe some performance hit due to indexing this one but not a blocker for staging3 merge since its already there.
osf_cache_table
osf_cache_table_expires
CREATE INDEX osf_cache_table_expires ON public.osf_cache_table USING btree (expires)
Finally, there is no difference between before-squash and after-squash (with indexes added in this PR).
Reference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Squash all migrations before upgrade and add not-auto-genarated
postgresindexes.Deployment Notes
Fortunately, on servers, we don't need to go through the steps that creates this PR. All we need to do is:
migrate --faketo take care of everythingChanges
Here is the step-by-step work flow on how the migrations in this PR are generated.
develop, make sure migrations are up-to-date.feature/django_upgradeosfmigrationsaddon_*migrationsshowmigrationsand verify the deletionmakemigrations: migrations will be created forosfand everyaddon_*showmigrationsagain to trigger the circular import error betweenosfand built-inadminshowmigrationsagain to verify the fixmigratewith--fakeonosfto trigger theNotableEmailDomainbugdefault=0in the migrationmigratewith--fakeonosfagain to fake the init migrationmigratewith--fakeon eachaddon_*to fake all each add-on's migrationsmakemigrationsto generate a new migration for the removed migration in Step 9migratewith--fakeonosfto fake the second OSF migrationmigratewith--fakeonosfto fake the third OSF migrationAbout the indexes update
Our initial approach is to rewrite all
RunSQLindexes update documented in Migrations Creating Indexes/Constraints but kept run into errors due to out-dated models. Thus, we switched the approach to generate a index diff that we can easily compare and pick the indexes to add.QA Notes
N/A
Documentation
N/A
Side Effects
N/A
Ticket
https://openscience.atlassian.net/browse/ENG-3998