mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-16 09:30:59 +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 */
|
/* Insert element in graph */
|
||||||
*dup = HnswInsertElement(element, entryPoint, NULL, procinfo, collation, m, efConstruction, false);
|
*dup = HnswInsertElement(element, entryPoint, NULL, procinfo, collation, m, efConstruction, false);
|
||||||
|
|
||||||
/* Update neighbors */
|
if (*dup == NULL)
|
||||||
for (int lc = element->level; lc >= 0; lc--)
|
|
||||||
{
|
{
|
||||||
int lm = HnswGetLayerM(m, lc);
|
/* Update neighbors */
|
||||||
HnswNeighborArray *neighbors = &element->neighbors[lc];
|
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++)
|
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 */
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user