Skip to main content

Getting Notes db/template version faster

While doing XPages application performance optimization, I discovered that one of the slowest parts was reading the template version and build date. I've never paid much attention to this code, so it surprised me. 

The code that we used was the standard code to get it

NoteCollection noteCollection;
noteCollection = db.createNoteCollection(true);
noteCollection.setSelectSharedFields(true);
noteCollection.setSelectionFormula("$TITLE=\"$TemplateBuild\"");
noteCollection.buildCollection();
final String noteID = noteCollection.getFirstNoteID();
...

But in this application, it normally took around 2 seconds just to call this noteCollection.buildCollection(). What was even worse, the first call of the day took 20s. I wasn't able to reproduce the 20s even after server restart, so that's still a mystery to me. The application is not huge - around 200 design elements and 100k normal document. 600MB in size.

I started to look for alternative approaches and a simple hint from HCL set me on the right track - can we use a view to get this information? 

Yes, you can customize a view to show design elements by adjusting $FormulaClass e.g. using LotusScript or ScanEZ. This way I created a view with:

$FormulaClass = 1024
Selection formula = SELECT $Title="$TemplateBuild"
and columns to show the $TemplacteBuild and $TemplateBuildDate

Then the code got even more simple :

View v = db.getView("($dbversion)");
ViewEntry ve = v.getAllEntries().getFirstEntry();
version = ve.getColumnValues().get(1).toString();
versiondate = ve.getColumnValues().get(2).toString();

Now the code gets the version instantly (I've seen numbers around 60ms at most). I can probably even set the view to "no refresh" as all the templates are fully recreated in CI/CD environment, so the design is completely replaced every time. 

We have such code in all application, mostly being read into an app-scope bean, but in some cases, it's just a customControl that's displayed somewhere on all pages. Nobody ever worried about performance. 


Comments

Popular posts from this blog

XPages EL/class-loader memory leak (now with solution)

 We have recently experienced OutOfMemory crashes of XPages app server. The server was recently upgraded to 12.0.1FP1, but we were getting some panic crashes in HTTP even before the upgrade (it was 9.0.1FP10). Our hopes were that the upgrade would stabilize the server, but it's not the case. At least now I start to see what's the problem.  update 8.12.2022 There were actually 3 different leaks. I have rewritten the article to be a bit more clear. I also re-run some of the tests on 9.0.1FP10, so I assume the problems are also in earlier versions. Problem 1 The server is hosting over 1000 NSF sharing the same design + some other custom apps. Not all NSFs are used via web as the app still has classic Notes UI in parallel, so it's a bit tricky to estimate the load. By using tell http xsp show modules I usually see around 350 NSFs active. We kept the default application timeout that should provide reasonable application recycling if it's not used continuously.  We started to

HCL Domino 12.0.2, Engage 2022 and HCL Factory tour Milan

 I haven't published my recap after Engage this year and the recent HCL Factory tour in Milan is a great opportunity to write a summary about what's happening in HCL (mostly Domino) space. It's a mix of news about 12.0.2, future directions, and my impressions, so it can be a bit chaotic, but I got the impression that many people see it similarly.  Engage 2022 Engage 2022 was great (as always). I love the atmosphere in Brudges. I visited it once after Engage a few years ago and I was happy to come back. This was also the first time I had the opportunity to speak at Engage, which obviously made it a bit more stressful, but also more fun. Together with Domino Jams, HCL continued conversations with customers and partners about the future of their products at Engage. Many of these ideas were now discussed in greater detail in Milan, some of them were even demoed.  My main takeaways from Engage were: Nomad (web and mobile) are a great addition to Notes family Restyle is a great g

Getting started with Domino AppDev Pack Java API - Part 1

 The newest Domino AppDev Pack release 1.0.6 added support for Java API. In past, we've seen many projects that tried to decouple Java APIs from Domino server, but except for the built-in DIIOP, all were community-driven and required some sort of bridge or fake Domino binaries package. This time we're getting brand new, officially supported API.  Domino AppDev Pack series: 1. First Java API (this) 2. Certificates 3.  Kotlin REST API I've never worked with Node.js based domino-db module, but I've seen several demos and I was well aware of the architecture. Even with all this knowledge, when I've checked the official documentation, I was pretty terrified. It looked like I need to be an experienced Domino admin, security specialist, and who knows what to just try to see how the new Java API. Luckily, if you just try to read between the lines, it's not that bad. HCL just documented the full pretty complex setup, which is not what you are looking for if you what to