hnswlib
hnswlib copied to clipboard
Complexity of add_items?
Hello everyone,
This is more a question than an issue. I want to know how the algorithm handles adding items and what's the complexity of this method. It can be split into 2 questions, basically: 1 - What is the complexity of the add_items method when the item is new? 2 - If the item already exists, what the complexity of updating it? 3 - Is it better to mark the item as deleted and then adding the updated embedding as a new item?
Thank you very much for your insight!
Hi @otmhi,
- The insertion complexity is somewhat comparable to a search complexity (you can think that it has a constant 2X or something multiplier overhead)
- Updating is much more expensive than insertion (I think something like tens of insertions to make the accuracy not degrade over time).
- That depends on the definition of "better". It is faster, but uses more memory and will degrade some performance at search time.