Iterating documents based on a view object has become very slow in later years. Maybe because of all the work that has been with NIF-index issues.
The following techniques show poor (some even very poor) performance when running in the client against a server database:
Set
view = dbSource.Getview(
"vCategoryOneCategory"
)
Set
vec = view.Getallentriesbykey(
"Documents"
,
True
)
Set
ve = vec.Getfirstentry()
While
Not
ve
Is
Nothing
Let
lCount = lCount +
1
Set
ve = vec.Getnextentry(ve)
Wend
Set
doc = view.Getfirstdocument()
While
Not
doc
Is
Nothing
Let
lCount = lCount +
1
Set
doc = view.Getnextdocument(doc)
Wend
Set
nav = view.Createviewnav()
Set
ve = nav.Getfirst()
While
Not
ve
Is
Nothing
Let
lCount = lCount +
1
Set
ve = nav.Getnext(ve)
Wend
Whereas the following show good (even very good) performance:
Set view = dbSource.Getview("vCategoryOneCategory")
Let view.Autoupdate = False
Set nav = view.Createviewnavfromcategory("Documents")
Let nav.Buffermaxentries = BUFFER_MAX_ENTRIES
Set ve = nav.Getfirst()
While Not ve Is Nothing Let lCount = lCount + 1
Set ve = nav.Getnext(ve)
Wend
Let view.Autoupdate = True
Set view = dbSource.Getview("vCategoryOneCategory")
Set dc = view.Getalldocumentsbykey("Documents",True)
Set doc = dc.Getfirstdocument()
While Not doc Is Nothing
Let lCount = lCount + 1
Set doc = dc.Getnextdocument(doc)
Wend
In very large databases the search takes longer, the looping is always fast.
Set dc = dbSource.Search(strFormula,Nothing,0)
Set doc = dc.Getfirstdocument()
Do Until doc Is Nothing
Let lCount = lCount + 1
Set doc = dc.Getnextdocument(doc)
Loop