This PR aims to improve performances as we are making A LOT of queries after having added events emission to the ORM layer. While investigating issues, I've come across multiple problems I will describe below ## Add index on workspace.activationStatus as we are querying it a lot As per title ## Add logs on core datasource destroy It seems that we have postgres connection pool destruction in production. I cannot reproduce locally but I suspect the Query Timeouts to be the root cause. I'm fixing most of the Query Timeouts cause in this PR but I'm adding the logs so we have more information in case in keeps happening in production. ## GraphQL query runner createMany It was using a for loop on each record. This is as issue has we will emit an event separately for each record => we should always try to batch events. Replacing by a save on all records. Note that this is not perfect as we should avoid using save (bad performances), and use insert + updateMany instead. As I have follow up discussions regarding permissions, I haven't replaced it by insert and updateMany yet. Using save instead of a for loop makes the problem less worrying. ## Introduce updateMany in ORM @Weiko @ijreilly FYI .save(manyRecords) is bad as it's querying the data for no good reason (and doing a select for each record...). We already have .insert(), i'm introducing .updateMany() I think our ORM layer should be simplified a lot but I'm not starting the refacto yet ## Fixing ORM @Weiko @ijreilly FYI - Fixing events emission in delete function - Fixing events emission in insert function - make sure everything is batched ## Events performance @Weiko @ijreilly FYI Do not emit timelineActivity db events as this does not seem useful and is quite heavy ## Messaging and Calendar performance @bosiraphael FYI Rework many functions to make sure they are batched. This does not touch the driver layer and I have heavily tested it. (multiple account, with multiple channels, common thread, common messages, etc...) ## Workflow Trigger relation Fetch performance @martmull FYI Improved performance by batching
The #1 Open-Source CRM
🌐 Website · 📚 Documentation · Roadmap ·
Discord ·
Figma
Installation
See:
🚀 Self-hosting
🖥️ Local Setup
Does the world need another CRM?
We built Twenty for three reasons:
CRMs are too expensive, and users are trapped. Companies use locked-in customer data to hike prices. It shouldn't be that way.
A fresh start is required to build a better experience. We can learn from past mistakes and craft a cohesive experience inspired by new UX patterns from tools like Notion, Airtable or Linear.
We believe in Open-source and community. Hundreds of developers are already building Twenty together. Once we have plugin capabilities, a whole ecosystem will grow around it.
What You Can Do With Twenty
Please feel free to flag any specific needs you have by creating an issue.
Below are a few features we have implemented to date:
- Personalize layouts with filters, sort, group by, kanban and table views
- Customize your objects and fields
- Create and manage permissions with custom roles
- Automate workflow with triggers and actions
- Emails, calendar events, files, and more
Personalize layouts with filters, sort, group by, kanban and table views
Customize your objects and fields
Create and manage permissions with custom roles
Automate workflow with triggers and actions
Emails, calendar events, files, and more
Stack
- TypeScript
- Nx
- NestJS, with BullMQ, PostgreSQL, Redis
- React, with Recoil, Emotion and Lingui
Thanks
Thanks to these amazing services that we use and recommend for UI testing (Chromatic), code review (Greptile), catching bugs (Sentry) and translating (Crowdin).
Join the Community
- Star the repo
- Subscribe to releases (watch -> custom -> releases)
- Follow us on Twitter or LinkedIn
- Join our Discord
- Improve translations on Crowdin
- Contributions are, of course, most welcome!




