Getfirstentry from a entry collection is slow - WHY?

Using the following code…basically:

find my mail db

open names.nsf on same server

get ($users) view

use my canonical name to return a view entry collection - this happens very quickly and returns a collection of size 1 as expected

set an entry = first entry of returned collection…you would expect this to be very fast, but it takes forever…appears to just hang and you get a network timeout. Is this an “anomaly” or did I screw up?

Sub Initialize

Dim s As New NotesSession

Dim addrdb As NotesDatabase

Dim maildb As New NotesDatabase(“”,“”)

Dim usersview As NotesView

Dim usersvec As NotesViewEntryCollection

Dim userve As NotesViewEntry

Call maildb.OpenMail

Set addrdb = New NotesDatabase(maildb.Server, “names.nsf”)

Set usersview = addrdb.GetView(“($Users)”)

’ ignore service ids

Set usersvec = usersview.GetAllEntriesByKey(Lcase(s.UserName))

Set userve = usersvec.GetFirstEntry

Print userve.columnvalues(9)

End Sub

Subject: getfirstentry from a entry collection is slow - WHY?

I’m experiencing the same thing for no apparent reason. I’m running Dom 6.5.4 on iSeries and getFirstEntry is very slow. On a script that uses it almost 2000 times, it is rediculously slow! So I tried using docs instead (getFirstDocument) and it is MUCH faster! The db is indexed, nothing changes except I get values using docs instead of view entries. Per cycle I save about 5 seconds using docs instead of entries. I don’t see why though.

Subject: RE: getfirstentry from a entry collection is slow - WHY?

It sounds like some sort of an auto refresh is happening. Does the view use time/date columns for sorting?

Subject: getfirstentry from a entry collection is slow - WHY?

How big is your N&A book? How many entries?Are you in a 100 people setup or in a 100,000 people setup? Do you have a fast server?

Getting the view entry collection handle is fast ebcause it is using the old index.

Getting the real data from the view is long because at this point Notes may have to refresh the old index, and if it is a huge base which has not been indexed in a while, it has to do it.

This being said, you are returning the 9th column. This column probably referes to a field on the document. Did you try getting the user’s document and getting the field from it instead of getting it from a vew entry? No idea if it will be faster through…

Hoping this helped,

Nicolas Abesdris

Quintessence e-solutions Inc.

Subject: RE: getfirstentry from a entry collection is slow - WHY?

Using viewEntries for getting column data should always be faster than using documents, since all operations are limited to the index itself.

Opening a view handle, or retrieving an entry from the view does also not refresh the on-disk index of the view. What it will do is perform a partial scan of the database to include notes that have been updated since the last index – this should happen when getting the view handle, not on the first entry!

Even with a huge NAB, this call should not time-out, so I guess something else may be wrong. Did you try rebuilding the view index (shift-F9).

cheers,

Bram