mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-04 03:30:56 +08:00
Improved performance for duplicates
This commit is contained in:
@@ -290,14 +290,17 @@ InsertTuple(Relation index, Datum *values, HnswElement element, HnswBuildState *
|
||||
/* Insert element in graph */
|
||||
*dup = HnswInsertElement(element, entryPoint, NULL, procinfo, collation, m, efConstruction, false);
|
||||
|
||||
/* Update neighbors */
|
||||
for (int lc = element->level; lc >= 0; lc--)
|
||||
if (*dup == NULL)
|
||||
{
|
||||
int lm = HnswGetLayerM(m, lc);
|
||||
HnswNeighborArray *neighbors = &element->neighbors[lc];
|
||||
/* Update neighbors */
|
||||
for (int lc = element->level; lc >= 0; lc--)
|
||||
{
|
||||
int lm = HnswGetLayerM(m, lc);
|
||||
HnswNeighborArray *neighbors = &element->neighbors[lc];
|
||||
|
||||
for (int i = 0; i < neighbors->length; i++)
|
||||
HnswUpdateConnection(element, &neighbors->items[i], lm, lc, NULL, NULL, procinfo, collation);
|
||||
for (int i = 0; i < neighbors->length; i++)
|
||||
HnswUpdateConnection(element, &neighbors->items[i], lm, lc, NULL, NULL, procinfo, collation);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update entry point if needed */
|
||||
|
||||
@@ -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