gristlabs / grist-core

Grist is the evolution of spreadsheets.
https://www.getgrist.com/
Apache License 2.0
7.04k stars 311 forks source link

FIX slowness when adding user to workspace #1205

Open hexaltation opened 2 weeks ago

hexaltation commented 2 weeks ago

Context

On French administration we can experience instances not beeing able to add users to workspaces due to long queries, and never ending queries.

Proposed solution

https://github.com/gristlabs/grist-core/commit/e26673eff10e93f7383f09886affdd999a2ecde4

To fix this issue we propose the same strategy than in #824. Splitting the query in to simpler queries to gather informations about workspace and organization.

https://github.com/gristlabs/grist-core/commit/bd43d12110c3ae33fa793b1d658e1a5c630a186a We also propose to remove the promisyfyAll around iteration of getUsers queries. During local test, it seems to be the main culprit. The ForEach iteration launches asynchonously many queries recycling the same transaction. Sometime the transaction never ended.

https://github.com/gristlabs/grist-core/commit/3c6388cb165fe79dbff57454caf2014247bfb53e Cause the newly added function getExistingUsersByLogin uses a WHERE on logins.email a INDEX is added to allow fastest queries.

Related issues

FIXES #1005

Has this been tested?