Add dataloader and read from cache for view entities (#18594)

## Context
Improve view resolution using cache and dataloader

## Performance Comparison

|Run|Main (no DataLoaders/cache)|Feature Branch (DataLoaders +
cache)|Speedup|
|---|---|---|---|
|1 (cold)|418ms|95ms|~4.4x faster|
|2|42ms|19ms|~2.2x faster|
|3|37ms|19ms|~1.9x faster|
|4|39ms|12ms|~3.2x faster|
|5|33ms|13ms|~2.5x faster|

The biggest improvement is to use dataloaders for the multiple relations
associated with views. Cache is a bit less significant since there are
other cache mechanism such as PostgreSQL buffer cache but it will
probably be more meaningful with bigger workspaces
This commit is contained in:
Weiko
2026-03-12 19:05:30 +01:00
committed by GitHub
parent a3c392ce8b
commit 1cb4c98cb3
12 changed files with 1121 additions and 737 deletions
@@ -9,6 +9,11 @@ import {
type RelationLoaderPayload,
type ViewFieldGroupsByViewIdLoaderPayload,
type ViewFieldsByViewFieldGroupIdLoaderPayload,
type ViewFieldsByViewIdLoaderPayload,
type ViewFilterGroupsByViewIdLoaderPayload,
type ViewFiltersByViewIdLoaderPayload,
type ViewGroupsByViewIdLoaderPayload,
type ViewSortsByViewIdLoaderPayload,
} from 'src/engine/dataloaders/dataloader.service';
import { type FieldMetadataDTO } from 'src/engine/metadata-modules/field-metadata/dtos/field-metadata.dto';
import { type RelationDTO } from 'src/engine/metadata-modules/field-metadata/dtos/relation.dto';
@@ -17,6 +22,10 @@ import { type IndexMetadataDTO } from 'src/engine/metadata-modules/index-metadat
import { type ObjectMetadataDTO } from 'src/engine/metadata-modules/object-metadata/dtos/object-metadata.dto';
import { type ViewFieldGroupDTO } from 'src/engine/metadata-modules/view-field-group/dtos/view-field-group.dto';
import { type ViewFieldDTO } from 'src/engine/metadata-modules/view-field/dtos/view-field.dto';
import { type ViewFilterGroupDTO } from 'src/engine/metadata-modules/view-filter-group/dtos/view-filter-group.dto';
import { type ViewFilterDTO } from 'src/engine/metadata-modules/view-filter/dtos/view-filter.dto';
import { type ViewGroupDTO } from 'src/engine/metadata-modules/view-group/dtos/view-group.dto';
import { type ViewSortDTO } from 'src/engine/metadata-modules/view-sort/dtos/view-sort.dto';
export interface IDataloaders {
relationLoader: DataLoader<RelationLoaderPayload, RelationDTO | null>;
@@ -55,4 +64,29 @@ export interface IDataloaders {
ViewFieldsByViewFieldGroupIdLoaderPayload,
ViewFieldDTO[]
>;
viewFieldsByViewIdLoader: DataLoader<
ViewFieldsByViewIdLoaderPayload,
ViewFieldDTO[]
>;
viewFiltersByViewIdLoader: DataLoader<
ViewFiltersByViewIdLoaderPayload,
ViewFilterDTO[]
>;
viewSortsByViewIdLoader: DataLoader<
ViewSortsByViewIdLoaderPayload,
ViewSortDTO[]
>;
viewGroupsByViewIdLoader: DataLoader<
ViewGroupsByViewIdLoaderPayload,
ViewGroupDTO[]
>;
viewFilterGroupsByViewIdLoader: DataLoader<
ViewFilterGroupsByViewIdLoaderPayload,
ViewFilterGroupDTO[]
>;
}