Improved performance for duplicates

This commit is contained in:
Andrew Kane
2023-08-10 08:52:45 -07:00
parent 6f15dd266c
commit 309fa94c05
2 changed files with 9 additions and 7 deletions

View File

@@ -290,6 +290,8 @@ InsertTuple(Relation index, Datum *values, HnswElement element, HnswBuildState *
/* Insert element in graph */ /* Insert element in graph */
*dup = HnswInsertElement(element, entryPoint, NULL, procinfo, collation, m, efConstruction, false); *dup = HnswInsertElement(element, entryPoint, NULL, procinfo, collation, m, efConstruction, false);
if (*dup == NULL)
{
/* Update neighbors */ /* Update neighbors */
for (int lc = element->level; lc >= 0; lc--) for (int lc = element->level; lc >= 0; lc--)
{ {
@@ -299,6 +301,7 @@ InsertTuple(Relation index, Datum *values, HnswElement element, HnswBuildState *
for (int i = 0; i < neighbors->length; i++) for (int i = 0; i < neighbors->length; i++)
HnswUpdateConnection(element, &neighbors->items[i], lm, lc, NULL, NULL, procinfo, collation); HnswUpdateConnection(element, &neighbors->items[i], lm, lc, NULL, NULL, procinfo, collation);
} }
}
/* Update entry point if needed */ /* Update entry point if needed */
if (*dup == NULL && (entryPoint == NULL || element->level > entryPoint->level)) if (*dup == NULL && (entryPoint == NULL || element->level > entryPoint->level))

View File

@@ -942,7 +942,6 @@ HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, F
} }
/* Look for duplicates */ /* Look for duplicates */
/* This must come last, since duplicate updates can fail */
if (level >= 0 && !vacuuming) if (level >= 0 && !vacuuming)
{ {
dup = HnswFindDuplicate(element); dup = HnswFindDuplicate(element);