Posts Tagged ‘@formula’

29 Aug 2012
6

Notes Database Performance Tip: Optimize Document Table Map

Hi Everyone. In the past few days I’ve been asked to audit a few Notes Applications. Apart from the usual disabling of unread marks and removing views no longer used to increase performance, there is a very important setting on a Notes Database and can drastically reduce the indexing time of Notes Views.

It’s called “Optimize Document Table Map“.

Firstly, a quick scenario:

Let’s say you have a Notes Application that contains about 5 different Forms. For each form you have about 3 – 5 Notes Views. Also for each Form you have about 5000-10000 documents.

When it comes to indexing Views, if the property “Optimize Document Table Map” is not selected in the Notes Database Properties, the following happens:

When indexing a certain View,  Notes will search through all documents created from all 5 Forms in the Database to produce the result in the View. If you only have a few hundred documents in the database, then this is not an issue. However, 50 000 documents later this could lead to poor performance of your Views.

 

So, let’s say that you have “Optimize Document Table Map” selected in the Notes Database Properties, the following will happen:

When indexing a certain View, Notes will only search through all records in the Database that were created using the Form that’s specified in the View Selection Formula. This means that if you have 5 Forms in the Database, and 5 000 records for each Form, Notes will only search through 5 000 records for a specific Form to index the Notes View. Can you imagine the Response Time :)

 

So, where to enable this setting? If you right-click on your Notes Database and go to the “Database Properties”, click on the last tab. You will see towards the Top that you can check the option “Optimize Document Table Map

 

2 Important Notes when enabling this Setting:

1. I’ve had varied results with enabling this property and just expecting it to work. I highly recommend compacting the database after enabling this Setting just to be sure.

2. In order for this setting to Work, it’s very important that your View Selection Formula for your Notes View specifies the Form Name.

i.e. If your View Selection Formula only says Select FirstName = “John”, then you won’t see a performance boost on the view. However, if you say Select Form = “Person” & FirstName = “John”, this will work because you are referencing the Form Name inside the View, which if you think about it, makes sense.

 

I hope this helps everyone. Happy Coding :)

John

28 Aug 2012
3

Important Tip when comparing values in Java

Hi everyone. Here’s a quick post that might save you a lot of time. With some programming languages like JavaScript, @Formula or LotusScript, to compare a String value is pretty simple

@Formula: tmp1 := “Test”;

tmp2 := “Test”;

(tmp1 = tmp2) = True


JavaScript:var tmp1 = “Test”;

var tmp2 = “Test”;

(tmp1 == tmp2) = True

 

LotusScript:dim tmp1 as String

dim tmp2 as Stringtmp1 = “Test”

tmp2 = “Test”

if(tmp1 = tmp2) = True

 

But when it comes to Java, the rules are slightly different:

String tmp1 = “Test”;

String tmp2 = “Other Test”;

(tmp1 == tmp2) = True

 

In Java, the == operator compares Objects and not the physical values contained within. The line above this is checking if the object tmp1 is the same object as tmp2.

So, in Java, the proper way to compare values is by using the equals() method:

String tmp1 = “Test”;

String tmp2 = “Test”;

(tmp1.equals(tmp2) = True

 

If it’s anything that I can teach you today, it’s that with Java almost everything is an Object and not just a data type. If it’s an Object, it has Properties and Methods that should be considered at all times, especially when parsing or comparing values.

Cheers for now :)

John

25 Oct 2011
3

XPages Tip: @Dblookup() and Javascript Array

I learned a valuable lesson yesterday. I declared a Javascript variable called myarray and wanted to assign a list generated from a DbLookup. The good news is that this works 99%. There is just 1 small exception. If the DbLookup only returns 1 value, it then passes that value as a string and not an array, even if you force it to be an array. See below example of how to get around this.

// Initiate the DB Lookup and pass it to the JS Variable

var mydb = new Array(database.getServer(),database.getFilePath());

var myarray = @DbLookup(mydb, “ViewAliasName”, “key”, 2);

// Make sure a value was returned, then make sure it’s an array   

if(myarray == undefined)

{

return false;

}

else if(myarray[0] == undefined)

{

var myarray = new Array( myarray );

}

24 Oct 2011
2

Lotus Notes Tip: Error Document Has Not Yet Being Saved

   If you’ve ever come across a Lotus Notes Error, where you click on a button in an Open Document which is in Edit Mode, where the Formula behind the button is an @Command( [RunAgent] ; “AgentName” ), and you receive an error “Document Has Not Yet Being Saved“, a most likely solution will be to set the “Target” parameter on the NotesAgent to “None“. Lotus does not like the target been set to “All Selected Documents”.

Unless I’m mistaken, you would not need the Target to be set to anything else in this particular scenario.

Cheers