Domino Code Fragment

Code Name*
Autorefresh all view indexes
Date*
07/22/1999
Source (or email address if you prefer)*
Jamie Magee
IP address:.3.138.125.139
Description*
Automatically refreshes all view indexes each night.
Type*
LotusScript
Categories*
Design Configuration, Replication
Implementation:
None (plug and play)
Required Client:
Server:
Limitations:
Comments:
Place this in an agent, "On Schedule Daily" to run after replication (or hourly for test purposes), to run on "All Documents in Database" (this setting is actually irrelevant for this code). The Notes Log will show how long it took for each view. This is the time we saved the user who would have opened this otherwise out-of-date view index.

Despite this document from Lotus below, sometimes the first user to open a big view each morning has to wait while it reindexes. This can be due to design changes in the view, pushed replication changed, or other factors.

http://support.lotus.com/sims2.nsf/802ee480bdd32d0b852566fa005acf8d/7005e0842fdf4d4085256695007558f6?OpenDocument

"What Triggers the Indexer?"

A view will be refreshed when any of the following occur:


1. Router - When the Router deposits a message in a mail database, it also places a corresponding request into the Update queue.

2. Replication - When databases replicate, the replicator places a request into the Update queue.

3. Server - When a user logs a session or closes a session and modifications have been made to a database, a request is added to the Update Queue.

Files/Graphics attachments (if applicable): Code:

Sub Initialize
    Dim S As New NotesSession
    Dim db As NotesDatabase
    Set db=S.currentDatabase
   
    Print "Start: Refreshing View Indexes for " & db.FilePath
   
    Forall v In db.views
         Print "...Refreshing view: " & v.Name
         Set doc = v.GetFirstDocument  '...cause the view index to refresh
    End Forall
   
    Print "End: Refreshing View Indexes for " & db.FilePath
End Sub