What is the time complexity of NotesView.GetDocumentByKey?

I’d imagine that it’s O( log n ), but I don’t want to get bitten down the road if it’s not…

Thanks,

Brandon.

Subject: What is the time complexity of NotesView.GetDocumentByKey?

Unnoticeable. No impact on performance.

Subject: What is the time complexity of …

I would say O(log n) would be accurate under most cases. Regardless you should consider the various ways of obtaining a handle to a document:

NotesDatabase.GetDocumentByUNID() - Typically the fastest possible way to access a document.

NotesDatabase.GetDocumentByID() - Also extremely fast, though testing shows it is not quite as fast as above.

NotesView.GetDocumentByKey() - Typically very fast, though getting your view handle can be expensive initially.

NotesDatabase.FTSearch() - Fairly slow, and requires a full-text index of your database. Typically the fastest way to obtain groups of documents based off of arbitrary values of data or in other scenarios where maintaining high numbers of views is performance prohibitive.

NotesDatabase.Search() - Very slow, especially as the number of documents in your database grows. Typically the most flexible type of search, allowing intra-document comparison (e.g. FieldA = FieldB / FieldC)

All of these are easy to test from a performance standpoint - just build yourself a quick test database, populate it with a bunch of docs and let `em rip.

Subject: RE: What is the time complexity of …

NotesDatabase.GetDocumentByUNID() - Typically the fastest possible way to access a document.

NotesDatabase.GetDocumentByID() - Also extremely fast, though testing shows it is not quite as fast as above.

Now that surprises me. The NotesID is (I though) a direct index into the database, while the UNID is just a name. I would have thought that Notes would have to lookup the NotesID of any document so that it could locate it in the database, and so it should be the fastest method.

(Not necessarraly the most usful method, as replications and database copies will change a document’s ID)

Subject: RE: What is the time complexity of …

The difference appears to be that ByID opens the doc, ByUnid doesn’t. So if you’re doing anything with the doc ByID will be faster than ByUnid+open.Here are some stats comparing ID/UNID/VIEW from 5.07, don’t know if anythings changed.

http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/0a94aeafcf89d53585256c21002f51f1?OpenDocument