Add indices on frequent queries (#12401)
Fixes #12165 Also changed the index naming convention because some were not properly name and would have caused conflicts in the long run
This commit is contained in:
@ -26,15 +26,27 @@ export enum KeyValuePairType {
|
||||
|
||||
@Entity({ name: 'keyValuePair', schema: 'core' })
|
||||
@ObjectType()
|
||||
@Unique('IndexOnKeyUserIdWorkspaceIdUnique', ['key', 'userId', 'workspaceId'])
|
||||
@Index('IndexOnKeyWorkspaceIdAndNullUserIdUnique', ['key', 'workspaceId'], {
|
||||
unique: true,
|
||||
where: '"userId" is NULL',
|
||||
})
|
||||
@Index('IndexOnKeyUserIdAndNullWorkspaceIdUnique', ['key', 'userId'], {
|
||||
unique: true,
|
||||
where: '"workspaceId" is NULL',
|
||||
})
|
||||
@Unique('IDX_KEY_VALUE_PAIR_KEY_USER_ID_WORKSPACE_ID_UNIQUE', [
|
||||
'key',
|
||||
'userId',
|
||||
'workspaceId',
|
||||
])
|
||||
@Index(
|
||||
'IDX_KEY_VALUE_PAIR_KEY_WORKSPACE_ID_NULL_USER_ID_UNIQUE',
|
||||
['key', 'workspaceId'],
|
||||
{
|
||||
unique: true,
|
||||
where: '"userId" is NULL',
|
||||
},
|
||||
)
|
||||
@Index(
|
||||
'IDX_KEY_VALUE_PAIR_KEY_USER_ID_NULL_WORKSPACE_ID_UNIQUE',
|
||||
['key', 'userId'],
|
||||
{
|
||||
unique: true,
|
||||
where: '"workspaceId" is NULL',
|
||||
},
|
||||
)
|
||||
export class KeyValuePair {
|
||||
@IDField(() => UUIDScalarType)
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
|
||||
Reference in New Issue
Block a user