When clicking the copy generic template button, we load generic templates and allow the user to select which one to copy a template from. We do this by querying all generic templates but we only send in a question ID to the query, which in the case of certain templates (e.g. Publications that appear in ISIS Direct) returns 10k+ templates, with the number growing every round. We are then doing a number of checks on every template's proposal, which involves fetching user details, before filtering out those that a user doesn't have permission to see. From limited testing I've seen this take anywhere from 30 seconds to over a minute locally with the new Postgres local database, even if the eventual list returned only contains a few templates.
These are the checks that are done on every template's proposal:
Note that if testing this on either local/dev/prod as a developer, isScientistToProposal() probably returns true and you can therefore see every single generic template (i.e. none are filtered out). I initially thought this was the reason for it being slow and dismissed it but it turns out it's unoptimised for everyone.
When clicking the copy generic template button, we load generic templates and allow the user to select which one to copy a template from. We do this by querying all generic templates but we only send in a question ID to the query, which in the case of certain templates (e.g. Publications that appear in ISIS Direct) returns 10k+ templates, with the number growing every round. We are then doing a number of checks on every template's proposal, which involves fetching user details, before filtering out those that a user doesn't have permission to see. From limited testing I've seen this take anywhere from 30 seconds to over a minute locally with the new Postgres local database, even if the eventual list returned only contains a few templates.
These are the checks that are done on every template's proposal:
Note that if testing this on either local/dev/prod as a developer,
isScientistToProposal()
probably returns true and you can therefore see every single generic template (i.e. none are filtered out). I initially thought this was the reason for it being slow and dismissed it but it turns out it's unoptimised for everyone.