Say you have an application with 1000+ documents in it. You want to create something to search over those documents and return any document of a certain type (form) and last processed over a set number of months. Would you use code like this? If so, how many documents would you expect to be processed?
sub DoSomething()
Dim maxPerRun as Integer
maxPerRun = 100
Dim numMonthsBack as Integer
numMonthsBack = 18
Dim searchStr As String
searchStr = |Form = “myForm” & @Adjust(someDate; 0; | + Cstr(numMonthsBack) + |; 0; 0; 0; 0) <= @Today|
Dim oldDocs as NotesDocumentCollection
Set oldDocs = lib_db.search(searchStr, Nothing, maxPerRun)
Dim myDocs List as NotesDocument
Set reqdoc = oldDocs.GetFirstDocument
While Not reqdoc Is Nothing
Set nextdoc = oldDocs.GetNextDocument(reqdoc)
myDocs(reqdoc.SomeField(0)) = reqdoc
Set reqdoc = nextdoc
Wend
‘’ do something with myDocs
End Sub
How many documents should be in ‘myDocs’ at the end of the while loop?
The result is not what I expected. I want to collect what people THINK should happen and compare it to what actually happens.
Subject: There isn’t definite answer…
How many documents should be in ‘myDocs’ at the end of the loop?
First, it depends on the set of unique values found in the SomeField of selected documents because you use them as list tags.
Second, maxPerRun=100 can limit the Count of collection but in my experience it doesn’t matter when iterating with getNextDocument.
Third (and most important), you can easily get “Insufficient memory” error working with many NotesDocument objects simultaneously.
Subject: Some valid points, but a lot of grey…
How many documents should be in ‘myDocs’ at the end of the loop?
First, it depends on the set of unique values found in the SomeField of selected documents because you use them as list tags.
I assume each tag is unique.
Second, maxPerRun=100 can limit the Count of collection but in my experience it doesn’t matter when iterating with getNextDocument.
This is the point I was trying to address. What should it do? If a NotesDocumentCollection has 100 elements, how many elements should it iterate over? That should not be a “grey area,” should it?
Third (and most important), you can easily get “Insufficient memory” error working with many NotesDocument objects simultaneously.
yes, this is true. that is why I assumed that 100/1000 were small enough not to matter.
Subject: Known Issue - IBM has an SPR
I contacted IBM and they have SPR RBEE4BPP3V to address this issue.
The problem is that the NotesDocumentCollection keeps iterating over results past the maximum document limit passed in to the search even though the NotesDocumentCollection SAYS its size is the maximum document count.