« Time Differences | Main| Welcome to the "Just Enough Governance for Lotus Notes" Blog »

Show Time

People who don't know me must think I came from a small town in Missouri. I'm from the part where not only must you show me, but I have to show it to myself. I recently heard a presentation on 10 functions to avoid and one of them was GetNth document. I thought that was kind of odd to be making a blanket statement like that so I had to find out for myself. I wrote a simple example to walk through some documents - one using GetFirst/GetNext and the other using GetNth.

So when I ran my example, I was surprised to find that GetNth was actually faster than GetNext. Let me say that again. On ND 7.0.1, Lotus has quietly improved the performance of GetNth so now it is actually faster than using a GetNext loop. But wait - there's more. Sure, for a small sample size it might be faster, but those of you in the real world have databases with thousands of documents. So yes, I did run my tests on a database with 40,000 documents. And GetNth was still faster. Now, it's not so much faster that I would go and re-code all my loops, but I certainly won't avoid using GetNth entirely.

(read more)


Working with document collections showed that GetNth was slower, but working with collections is waaaaaaaaaaaaaay slower than views - I couldn't wait for the collection to process 40,000 documents so I only had it do 4,000. So, if you can't make a view to walk through your documents, you probably want to stick to getFirst - getNext

Which all just goes to show you not to just accept whatever anybody tells you - sometimes you need to re-evaluate those old habits and beliefs.

By the way, here are some results using views and collections. This information was generated by Teamstudio Profiler.

Profiler screenshot showing results

Category    

Comments

1 - I remember a session about performance at Lotusphere a few years ago (6.5 timeframe perhaps?) where he pointed out that GetNthDocument in a view is as fast as GetFirstDocument/GetNextDocument. In views it has been fast in previous versions as well.
It would be interesting to know how the internal code of GetNthDocument have changed, in the past it contained one GetFirstDocument followed by n-1 GetNextDocument, which of course made it slow in loops.


Post A Comment

Feeds

Custom Button Custom Button

Category Cloud

Disclaimer

The views expressed by the authors on this blog do not necessarily reflect the views of Teamstudio, those who link to this blog, or even the author’s mother, father, sister, brother, uncle, aunt, grandparents, cousins, step relations, any other blood relative - and sometimes not even the author himself or herself.

Comments on this website are the sole responsibility of their writers and it is assumed those writers will take full responsibility, liability, and blame for any libel or litigation that results from something written in, or as a direct result of something written in, a comment. The accuracy, completeness, veracity, honesty, exactitude, factuality and politeness of comments are not guaranteed. Oh, how they are SO not guaranteed.
en-us,en;q=0.5OFFCCBot/1.0 (+http://www.commoncrawl.org/bot.html)38.107.179.213www.getthemostfromnotes.comHTTP/1.180Lotus-Domino/tsblog.nsf/D6Plinks/GetNthDocument_vs_GetNextDocument