mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 12:15:47 -04:00
redundant switch
This commit is contained in:
parent
32f25580ec
commit
d656cc2198
@ -168,22 +168,7 @@ export class DatabaseRepository {
|
|||||||
indexname: string;
|
indexname: string;
|
||||||
}>`SELECT indexdef, indexname FROM pg_indexes WHERE indexname = ANY(ARRAY[${sql.join(names)}])`.execute(this.db);
|
}>`SELECT indexdef, indexname FROM pg_indexes WHERE indexname = ANY(ARRAY[${sql.join(names)}])`.execute(this.db);
|
||||||
|
|
||||||
let keyword: string;
|
|
||||||
const vectorExtension = await getVectorExtension(this.db);
|
const vectorExtension = await getVectorExtension(this.db);
|
||||||
switch (vectorExtension) {
|
|
||||||
case DatabaseExtension.VECTOR: {
|
|
||||||
keyword = 'using hnsw';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DatabaseExtension.VECTORCHORD: {
|
|
||||||
keyword = 'using vchordrq';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DatabaseExtension.VECTORS: {
|
|
||||||
keyword = 'using vectors';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
for (const indexName of names) {
|
for (const indexName of names) {
|
||||||
@ -195,9 +180,14 @@ export class DatabaseRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (vectorExtension) {
|
switch (vectorExtension) {
|
||||||
case DatabaseExtension.VECTOR:
|
case DatabaseExtension.VECTOR: {
|
||||||
|
if (!row.indexdef.toLowerCase().includes('using hnsw')) {
|
||||||
|
promises.push(this.reindexVectors(indexName));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case DatabaseExtension.VECTORS: {
|
case DatabaseExtension.VECTORS: {
|
||||||
if (!row.indexdef.toLowerCase().includes(keyword)) {
|
if (!row.indexdef.toLowerCase().includes('using vectors')) {
|
||||||
promises.push(this.reindexVectors(indexName));
|
promises.push(this.reindexVectors(indexName));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -214,7 +204,7 @@ export class DatabaseRepository {
|
|||||||
const targetLists = this.targetListCount(count);
|
const targetLists = this.targetListCount(count);
|
||||||
this.logger.log(`targetLists=${targetLists}, current=${lists} for ${indexName} of ${count} rows`);
|
this.logger.log(`targetLists=${targetLists}, current=${lists} for ${indexName} of ${count} rows`);
|
||||||
if (
|
if (
|
||||||
!row.indexdef.toLowerCase().includes(keyword) ||
|
!row.indexdef.toLowerCase().includes('using vchordrq') ||
|
||||||
// slack factor is to avoid frequent reindexing if the count is borderline
|
// slack factor is to avoid frequent reindexing if the count is borderline
|
||||||
(lists !== targetLists && lists !== this.targetListCount(count * VECTORCHORD_LIST_SLACK_FACTOR))
|
(lists !== targetLists && lists !== this.targetListCount(count * VECTORCHORD_LIST_SLACK_FACTOR))
|
||||||
) {
|
) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user