SERIOUS Domino web scalability bug - Hotspot formulas are evaluated on form/document *open* via web

Ok, here’s an interesting one. Picture an empty form with a single hotspot. On that hotspot is an @Formula:

@DbLookup(“”; @Dbname; “BigView”; “Key”; 2);

“BigView” has about 150,000 documents, each with complex readers fields. This makes the @DbLookup very CPU-intensive (15 seconds of max CPU on a P-III 600mhz).

Obviously clicking the hotspot over the web causes a huge tax in server resources as the formula is processed. No problem there – we all know the ramifications of complex views, etc. The problem, though, is that merely opening the form via the web (http://…db.nsf/theForm?OpenForm) takes just as long – the @DbLookup is being processed anyway!

Opening or editing a document that uses the form has the same effect.

It’s as if Domino is executing the formula anyway. In fact, if you change the hotspot formula to…

@Return(“”);

@DbLookup(“”; @Dbname; “BigView”; “Key”; 2);

…then the form or doc opens lightning-quick. This obviously destroys the intended functionality of your hotspot, though.

If anybody here has scalability problems with Domino on the web then you may want to seriously have a look at this issue. I’ve got a ticket open with Lotus Support and will post updates here.

Subject: SERIOUS Domino web scalability bug - Hotspot formulas are evaluated on form/document open via web.

Isn’t this really the same issue that has always been true of forms and lookups? Is the lookup supposed to populate a keyword field or something similar? If so, change the logic to:

@If(@IsDocBeingEdited; @DbLookup(“”; @Dbname; “BigView”; “Key”; 2); “”)

or something similar.

Subject: Re: SERIOUS Domino web scalability bug - Hotspot formulas are evaluated on form/document open via web.

You’d think so, but remember - this is a hotspot. The formula shouldn’t be evaluated unless the hotspot is clicked.

If this was a field formula (either a computed-for-display field, editable field with a default value, etc.) then I would expect it to be executed on-open. But not when it’s on a hotspot.

A workaround could be some sort of formula in the hotspot such as @IsThisHotspotBeingClicked, but that seems a bit ridiculous, don’t you think?

Subject: RE: Re: SERIOUS Domino web scalability bug - Hotspot formulas are evaluated on form/document open via web.

What is the formula? Normally a hotspot doesn’t need to do a lookup, but is there any way to reconfigure the logic so that it doesn’t need to? The problem is partly that the web browser renders the HTML, so it needs to know what to render, and I think you are getting caught because it thinks it needs the result to know what to render.

Subject: RE: Re: SERIOUS Domino web scalability bug - Hotspot formulas are evaluated on form/document open via web.

The formula is an @DbLookup, nothing more. Originally it involved an @UrlOpen (to determine where to take the user after they clicked the hotspot), but stripping it down to just:

@DbLookup(“”; @Dbname; “BigView”; “Key”; 2);

…still causes the problem.

The problem is partly that the web browser renders the HTML, so it needs to know what to render, and I think you are getting caught because it thinks it needs the result to know what to render.

That’s exactly my point - on the web an @formula hotspot should never be evaluated on-render. It should only be evaluated on-click (i.e. when the javascript do_click() function in the resulting HMTL runs).

Subject: RE: Re: SERIOUS Domino web scalability bug - Hotspot formulas are evaluated on form/document open via web.

“I think you are getting caught because it thinks it needs the result to know what to render.”

How would this possibly be the case? An action hotspot on a form that, when clicked, evaluates anything in @formulas is doing nothing but returning a javascript doClick event generated by the HTTP rendered on the server. The web browser never has awareness of the @formula behind the button.

The HTTP server does need an awareness of the formula behind the button, but not until it’s clicked. There’s no conceivable reason for the HTTP server to evaluate that formula before sending the doClick code to the browser, because it’s only the HTTP server that’s going to evaluate the actual @formula code anyway, and it obviously has the benefit of the full Domino API.

This is EXACTLY the same technique used to optimize forms in Notes 3, where, instead of setting up a keyword field using an @DbLookup to retrieve a long list of items, you’d put a button next to the field, which when clicked, would do the lookup and then show the options in an @Prompt. The ENTIRE reason people did this was to not execute the @DbLookup until the user requested it.

Think of this another way… what if the button did an @MailSend? Would you want the mail to be sent whenever the form was rendered, rather than when the button was actually clicked? Of course not!

Erik’s identified a nasty bug that makes me particularly glad that I’m not doing web dev on Domino these days, since he’ll probably be waiting months for a fix.

Subject: SERIOUS Domino web scalability bug - Hotspot formulas are evaluated on form/document open via web.

Eric,

to my understanding this might not be a but a slight conceptual misunderstanding. As it is a hotspot (opposed to an action button), I believe that the HTTP task might want to actually render this to HTML before sending the (web) document to the browser.

Perhaps you want to check the HTML code that comes with the page - on Internet Explorer, that’s on the VIEW - SOURCE CODE menu. Do you find the @dblookup results somwhere in there?

An alternative approach might be to only launch an agent on the hotspot, which then retrieves the data and refreshes the web frontend.

Subject: RE: SERIOUS Domino web scalability bug - Hotspot formulas are evaluated on form/document open via web.

The @Dblookup results are not present - the HTML merely contains a “return doclick()” operation that is standard with all @formula action hotspots rendered over the web.

Perhaps you want to check the HTML code that comes with the page - on Internet Explorer, that’s on the VIEW - SOURCE CODE menu. Do you find the @dblookup results somwhere in there?

That’s exactly my point - the @Dblookup isn’t returning anything that’s needed at all by anything else on the page – it’s a hotspot, not a computed field, default value, etc. It’s a hotspot that, when clicked, runs the @dblookup. It could then set a field on the doc as a result of the lookup, or anything else for that matter, but for testing and example purposes all that is on the hotspot currently is the @dblookup itself.

Also, something new: if you hide the hotspot from web browsers it is still executing the @Dblookup within the hotspot when the form is opened.

Subject: Is javascript enabled on the db?

Don’t know if this has anything to do with it, but it’s a knee-jerk reaction: http://www-12.lotus.com/ldd/doc/domino_notes/Rnext/help6_designer.nsf/855dc7fcfd5fec9a85256b870069c0ab/b867db2b96830e5a85256c54004b62da?OpenDocument

Subject: RE: Is javascript enabled on the db?

Thanks for the link. Yes, “Use Javascript” is most definitely enabled. The hotspot is generating an onclick event in the HTML with the standard “return doclick(…)” function call.

Sounds like the behavior is not following what the documentation says…

If you select “Use JavaScript”

If you don’t select “Use JavaScript”

Display: Documents and navigators display faster because hotspot formulas are not evaluated until users click each hotspot.

And also…

Domino does not check the formulas before displaying pages.