mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-19 02:34:32 +08:00
Improved performance for duplicates
This commit is contained in:
@@ -290,6 +290,8 @@ InsertTuple(Relation index, Datum *values, HnswElement element, HnswBuildState *
|
||||
/* Insert element in graph */
|
||||
*dup = HnswInsertElement(element, entryPoint, NULL, procinfo, collation, m, efConstruction, false);
|
||||
|
||||
if (*dup == NULL)
|
||||
{
|
||||
/* Update neighbors */
|
||||
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++)
|
||||
HnswUpdateConnection(element, &neighbors->items[i], lm, lc, NULL, NULL, procinfo, collation);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update entry point if needed */
|
||||
if (*dup == NULL && (entryPoint == NULL || element->level > entryPoint->level))
|
||||
|
||||
@@ -942,7 +942,6 @@ HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, F
|
||||
}
|
||||
|
||||
/* Look for duplicates */
|
||||
/* This must come last, since duplicate updates can fail */
|
||||
if (level >= 0 && !vacuuming)
|
||||
{
|
||||
dup = HnswFindDuplicate(element);
|
||||
|
||||
Reference in New Issue
Block a user