Manage Learn to apply best practices and optimize your operations.

Reduce the Unk Design Size (Notes 4)

We have a db that has reached it's 64K UNK limit, which means there is no longer room to add any more unique fields to the design, or even to paste in any documents from other db's and other sick side-effects. This is a problem.

We know that reducing the number of unique fields in the UNK table will help to alleviate this problem. We used a util from Lotus to count the number of fields in all forms in the design. This totalled around 1,500 fields. Counting the fields in the design *plus all docs* gave 3,200 fields.

Therefore, there are a lot of fields mentioned in the UNK that are referenced only in old *documents*; documents for which a form no longer exists/exists but no longer contains these fields.

There are a few things you can do to reduce the size of the design, but the main thing is to remove fields in these documents that no longer exist in the design.

That's what this agent can do. It takes the document, gets the corresponding form from the design (if it exists), then compares all the items on the document to those in the design. It then actions spurious fields (lists them in this example), before getting the next document.

As it is, the agent simply logs where fields are spurious to a text file. You can easily modify the agent to remove the item from the document, so that when the database compacts again, the UNK is rebuilt and should be smaller.

Notes: I saw an agent around these parts that does something similar (I think), but it is rumored to hang when acting on a lot of documents. Mine has red-screened after about 5,000, but maybe the server was just too busy. That's why it now does things one view at a time. So far so good.

Before you start:

YOUR_VIEW = Your view name.
SOME_UNIQUE_FIELD = replace with some relevant field in your documents, so you can identify them in the log for further investigation.

You also need this function declaring the design pane (this came from Lotus411 - thanks):

 Public Function inArray (Element As String, Elements As Variant, CaseSensitive As Integer) As Integer Dim tmpString As Integer inArray = False For tmpString = 0 To Ubound (Elements) If CaseSensitive Then If Ucase(Element) = Ucase(Elements (tmpString)) Then inArray = True Else If Element = Elements (tmpString) Then inArray = True End If Next End Function


 Sub Initialize Dim session As New NotesSession Dim db As NotesDatabase Dim IA_Docs As NotesDocumentCollection Dim doc As NotesDocument Dim i As Integer Dim view As NotesView Dim Form_Matched_Flag As Integer Dim Form_Fields Dim Docs_Form_Name As String Dim Doc_Fields Dim akas As Variant Open "c:\temp\view_unused.txt" For Output Access Write Lock Write As 1 ' Set db = session.CurrentDatabase Set view = db.GetView("YOUR_VIEW") 'Set view. Set doc=view.GetFirstDocument Do Until (doc Is Nothing)'loop through all docs. Docs_Form_Name=doc.Form(0) 'get form used by doc. Print #1, Print "" Print #1,"Processing Document " & doc.SOME_UNIQUE_FIELD(0) & " using form " & Docs_Form_Name Print "Processing Document " & doc.SOME_UNIQUE_FIELD(0) & " using form " & Docs_Form_Name Form_Matched_Flag=0 'sets to 1 when we get a matching form, from the forall f loop below. Forall f In db.forms 'cycle through db's forms for a match. akas = f.Aliases If Isempty(akas)Then 'form has no aliases, so don't check Docs_Form_Name being in aliases here. If f.name=Docs_Form_Name Then Form_Matched_Flag=1 Form_Fields = f.Fields 'build list of all fields in this form. Forall x In doc.Items 'compare all fields in this doc to the ones in the design's form. If Not inArray(x.name, Form_Fields, 0) Then 'log that this field isn't in the form. Print #1,"Spurious Field in " & f.name & ", Field: " & x.name & "Document: " & doc.SOME_UNIQUE_FIELD(0) Print "Spurious Field in " & f.name & ", Field: " & x.name & "Document: " & doc.SOME_UNIQUE_FIELD(0) End If End Forall End If ' docs name matched without needing to check aliases. Else 'form HAS aliases, so check to see if Docs_Form_Name is amongst them. If inArray(Docs_Form_Name, akas, 0) Then 'found a match - this form is the one the doc uses. Form_Matched_Flag=1 Form_Fields = f.Fields 'build list of all fields in this form. Forall x In doc.Items 'compare all items in this doc v. the form fields assigned above. If Not inArray(x.name, Form_Fields, 0) Then 'log that this DOC field isn't in the form. Print #1,"Spurious Field in " & f.name & ", Field: " & x.name & " ,Document: " & doc.SOME_UNIQUE_FIELD(0) Print "Spurious Field in " & f.name & ", Field: " & x.name & " ,Document: " & doc.SOME_UNIQUE_FIELD(0) End If End Forall End If 'name *was* in aliases array. End If 'form had aliases. If Form_Matched_Flag=1 Then Exit Forall 'skip pointless looping through the rest of the forms as we found a match on this pass. End If End Forall 'bring next form from design and compare as above. If Form_Matched_Flag=0 Then 'we went through all forms and still didn't match the one used by the doc. Print #1,"*** No form found matching " & Docs_Form_Name & " in this document, Document: " & doc.SOME_UNIQUE_FIELD(0) Print "No form found matching " & Docs_Form_Name & " in this document, Document: " & doc.SOME_UNIQUE_FIELD(0) End If Set doc = view.getnextdocument(doc)

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close