Create indexes in django models and migration files#7568
Open
acwhite211 wants to merge 9 commits intomainfrom
Open
Create indexes in django models and migration files#7568acwhite211 wants to merge 9 commits intomainfrom
acwhite211 wants to merge 9 commits intomainfrom
Conversation
Triggered by 66a7b84 on branch refs/heads/issue-7482
Member
Author
|
Let me know if anyone thinks of any additional fields that they think would benefit from indexing? |
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.
Fixes #7482
Create indexes mentioned in the issue into the models and migration files. Some of the indexes mentioned were already present in the existing model, the rest have been added.
The main downside I could see is with adding the tree field indexes is that writes might be too slow. With an index like
taxon.name, write operations like INSERT, UPDATE, and DELETE will take longer, but with the upside of read operations being faster. I know that some of our tree operations make bulk edits to the tree record fields, like the 'Move' action in the tree viewer, so we'll want to be careful in our performance evaluation testing. We'll want to test this on large databases with a big taxon tree to make sure the read and write performance is acceptable.I ran into a problem with the tree viewer timing out after running the index migrations. Solved the issue by rewriting the
get_tree_rows()function to avoid the expensive grouped self-join on tree tables. Instead of joining child and synonym rows and collapsing them with GROUP BY, it now computes child counts and synonym lists with correlated subqueries, which preserves the same response shape while producing a faster query for taxon tree requests.Indexed fields
agentidentifieridentifier,identifiertypeagentspecialtyordernumber,specialtynameagentvariantnameattachmentmetadatanameauthorordernumbercollectionobjectname,projectnumbercollectionobjectgroupguid,namecollectionobjectgrouptypenamecollectionobjectpropertyguidcollectionobjecttypenamecollectionreltypenameexchangeinexchangeinnumberexsiccataitemnumbergeographycommonname,guid,highestchildnodenumber,nodenumbergeographytreedefnamegeographytreedefitemnamegeologictimeperiodhighestchildnodenumber,nodenumbergeologictimeperiodtreedefnamegeologictimeperiodtreedefitemnameinstitutionnetworkaltnamelatlonpolygonnamelithostrathighestchildnodenumber,nodenumberlithostrattreedefnamelithostrattreedefitemnamelocalityguidmaterialsampleguidmorphbankviewviewnameotheridentifieridentifierpicklistfieldname,filterfieldname,tablenamepreparationpropertyguidpreptypenamereferenceworklibrarynumberspauditlogfieldfieldnamespecifyusernamespexportschemaschemanamespexportschemaitemfieldnamespexportschemaitemmappingexportedfieldnamespexportschemamappingmappingnamespfieldvaluedefaultfieldname,tablenamesplocalecontainerpicklistnamesplocalecontaineritempicklistname,weblinknamesppermissionnamespprincipalnamespquerycontextnamespqueryfieldfieldname,formatnamespviewsetobjfilenamestoragehighestchildnodenumber,nodenumberstoragetreedefnamestoragetreedefitemnametaxoncultivarname,groupnumber,highestchildnodenumber,nodenumbertaxontreedefnametaxontreedefitemnametectonicunitfullname,guid,highestchildnodenumber,name,nodenumbertectonicunittreedefnametectonicunittreedefitemnamevoucherrelationshipvouchernumberChecklist
self-explanatory (or properly documented)
Testing instructions