-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Django Upgrade] [ENG-3998] Migration Clean squash + Update RunSQL
Indexes
#10028
[Django Upgrade] [ENG-3998] Migration Clean squash + Update RunSQL
Indexes
#10028
Conversation
fa82935
to
c4322af
Compare
RunSQL
Indexes
376d48a
to
fcff72a
Compare
RunSQL
IndexesRunSQL
Indexes
51ae779
to
ac1e404
Compare
ac1e404
to
699fc1c
Compare
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More on indexes update
Indexes Comparision
- On
prod
server, there are 922 indexes- See pg_indexes_prod
- In
local
env ondevelop
, there are 944 - 21 (silk) = 923 indexes - In
local
env onfeature/django_upgrade
, there are 945 - 21 (silk) = 924 indexes - In
local
evn 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.
Institution
inheritsLoggable
, 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).
Purpose
Squash all migrations before upgrade and add not-auto-genarated
postgres
indexes.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 --fake
to 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_upgrade
osf
migrationsaddon_*
migrationsshowmigrations
and verify the deletionmakemigrations
: migrations will be created forosf
and everyaddon_*
showmigrations
again to trigger the circular import error betweenosf
and built-inadmin
showmigrations
again to verify the fixmigrate
with--fake
onosf
to trigger theNotableEmailDomain
bugdefault=0
in the migrationmigrate
with--fake
onosf
again to fake the init migrationmigrate
with--fake
on eachaddon_*
to fake all each add-on's migrationsmakemigrations
to generate a new migration for the removed migration in Step 9migrate
with--fake
onosf
to fake the second OSF migrationmigrate
with--fake
onosf
to fake the third OSF migrationAbout the indexes update
Our initial approach is to rewrite all
RunSQL
indexes 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