Improve performance on metadata computation (#12785)
In this PR: ## Improve recompute metadata cache performance. We are aiming for ~100ms Deleting relationMetadata table and FKs pointing on it Fetching indexMetadata and indexFieldMetadata in a separate query as typeorm is suboptimizing ## Remove caching lock As recomputing the metadata cache is lighter, we try to stop preventing multiple concurrent computations. This also simplifies interfaces ## Introduce self recovery mecanisms to recompute cache automatically if corrupted Aka getFreshObjectMetadataMaps ## custom object resolver performance improvement: 1sec to 200ms Double check queries and indexes used while creating a custom object Remove the queries to db to use the cached objectMetadataMap ## reduce objectMetadataMaps to 500kb <img width="222" alt="image" src="https://github.com/user-attachments/assets/2370dc80-49b6-4b63-8d5e-30c5ebdaa062" /> We used to stored 3 fieldMetadataMaps (byId, byName, byJoinColumnName). While this is great for devXP, this is not great for performances. Using the same mecanisme as for objectMetadataMap: we only keep byIdMap and introduce two otherMaps to idByName, idByJoinColumnName to make the bridge ## Add dataloader on IndexMetadata (aka indexMetadataList in the API) ## Improve field resolver performances too ## Deprecate ClientConfig
This commit is contained in:
+1
-1
@@ -80,5 +80,5 @@ export class IndexMetadataEntity {
|
||||
default: IndexType.BTREE,
|
||||
nullable: false,
|
||||
})
|
||||
indexType?: IndexType;
|
||||
indexType: IndexType;
|
||||
}
|
||||
|
||||
+8
-2
@@ -106,7 +106,10 @@ export class IndexMetadataService {
|
||||
|
||||
async recomputeIndexMetadataForObject(
|
||||
workspaceId: string,
|
||||
updatedObjectMetadata: ObjectMetadataEntity,
|
||||
updatedObjectMetadata: Pick<
|
||||
ObjectMetadataEntity,
|
||||
'nameSingular' | 'isCustom' | 'id'
|
||||
>,
|
||||
) {
|
||||
const indexesToRecompute = await this.indexMetadataRepository.find({
|
||||
where: {
|
||||
@@ -232,7 +235,10 @@ export class IndexMetadataService {
|
||||
|
||||
async createIndexRecomputeMigrations(
|
||||
workspaceId: string,
|
||||
objectMetadata: ObjectMetadataEntity,
|
||||
objectMetadata: Pick<
|
||||
ObjectMetadataEntity,
|
||||
'nameSingular' | 'isCustom' | 'id'
|
||||
>,
|
||||
recomputedIndexes: {
|
||||
indexMetadata: IndexMetadataEntity;
|
||||
previousName: string;
|
||||
|
||||
+2
@@ -8,4 +8,6 @@ export interface IndexFieldMetadataInterface {
|
||||
fieldMetadata: FieldMetadataInterface;
|
||||
indexMetadata: IndexMetadataInterface;
|
||||
order: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
+7
@@ -1,7 +1,14 @@
|
||||
import { IndexFieldMetadataInterface } from 'src/engine/metadata-modules/index-metadata/interfaces/index-field-metadata.interface';
|
||||
|
||||
import { IndexType } from 'src/engine/metadata-modules/index-metadata/index-metadata.entity';
|
||||
|
||||
export interface IndexMetadataInterface {
|
||||
id: string;
|
||||
name: string;
|
||||
isUnique: boolean;
|
||||
indexFieldMetadatas: IndexFieldMetadataInterface[];
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
indexWhereClause: string | null;
|
||||
indexType: IndexType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user