twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
GNU Affero General Public License v3.0
15.7k stars 1.7k forks source link

Performance improvements on metadata and core schemas #4346

Open charlesBochet opened 6 months ago

charlesBochet commented 6 months ago

Scope & Context

We have noticed that the following indexes/foreign keys are missing: 1) metadata."workspaceCacheVersion"(workspaceId) should be converted to UUID 2) metadata."workspaceCacheVersion"(workspaceId) should have a foreign key to core.workspace(id) + onDelete Cascade 3) metadata."workspaceCacheVersion"(workspaceId) should be indexed 4) metadata."fieldMetadata" should have a composite index on (objectMetadata, workspaceId) 5) metadata."relationMetadata" should have two indexes on (toObjectMetadataId) + (fromObjectMetadataId)

Technical inputs

charlesBochet commented 6 months ago

@magrinj @Weiko FYI

Ariyamandebnath commented 4 weeks ago

hello @charlesBochet ,as my first contribution to the project can this issue be assigned to me.

charlesBochet commented 3 weeks ago

sure! Could you also make a benchmark before after? (you can use npx nx run twenty-server:command workspace:seed:demo and add DEMO_WORKSPACE_IDS=171a8c8f-73ba-4edb-b2b2-1facb657f37e,171a8c8f-73ba-4edb-b2b2-1facb657f37f, ... in your twenty-server .env)