perf(core): Aggregate workflow statistics to avoid hot-row contention (#33045)

This commit is contained in:
Iván Ovejero
2026-07-06 13:11:18 +02:00
committed by GitHub
parent b610b42558
commit 378710072f
18 changed files with 1245 additions and 88 deletions
+9
View File
@@ -119,6 +119,7 @@ Auto-generated from the PostgreSQL migrations in @n8n/db. Do not edit by hand.
| [public.workflow_publish_history](public.workflow_publish_history.md) | 6 | | BASE TABLE |
| [public.workflow_published_version](public.workflow_published_version.md) | 4 | | BASE TABLE |
| [public.workflow_statistics](public.workflow_statistics.md) | 7 | | BASE TABLE |
| [public.workflow_statistics_delta](public.workflow_statistics_delta.md) | 6 | | BASE TABLE |
| [public.workflows_tags](public.workflows_tags.md) | 2 | | BASE TABLE |
## Stored procedures and functions
@@ -1372,6 +1373,14 @@ erDiagram
varchar_36_ workflowId
varchar_128_ workflowName
}
"public.workflow_statistics_delta" {
timestamp_3__with_time_zone createdAt
bigint id
varchar_128_ name
smallint rootCountDelta
varchar_36_ workflowId
varchar_128_ workflowName
}
"public.workflows_tags" {
varchar_36_ tagId FK
varchar_36_ workflowId FK
@@ -0,0 +1,49 @@
# public.workflow_statistics_delta
## Columns
| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP | false | | | |
| id | bigint | | false | | | |
| name | varchar(128) | | false | | | |
| rootCountDelta | smallint | | false | | | |
| workflowId | varchar(36) | | false | | | |
| workflowName | varchar(128) | | true | | | |
## Constraints
| Name | Type | Definition |
| ---- | ---- | ---------- |
| workflow_statistics_delta_createdAt_not_null | n | NOT NULL "createdAt" |
| workflow_statistics_delta_id_not_null | n | NOT NULL id |
| workflow_statistics_delta_name_not_null | n | NOT NULL name |
| workflow_statistics_delta_pkey | PRIMARY KEY | PRIMARY KEY (id) |
| workflow_statistics_delta_rootCountDelta_not_null | n | NOT NULL "rootCountDelta" |
| workflow_statistics_delta_workflowId_not_null | n | NOT NULL "workflowId" |
## Indexes
| Name | Definition |
| ---- | ---------- |
| workflow_statistics_delta_pkey | CREATE UNIQUE INDEX workflow_statistics_delta_pkey ON public.workflow_statistics_delta USING btree (id) |
## Relations
```mermaid
erDiagram
"public.workflow_statistics_delta" {
timestamp_3__with_time_zone createdAt
bigint id
varchar_128_ name
smallint rootCountDelta
varchar_36_ workflowId
varchar_128_ workflowName
}
```
---
> Generated by [tbls](https://github.com/k1LoW/tbls)