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)
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.
Category Performance Tips and Tricks Coding Practices Development
Comments
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.
Posted by Karl-Henry Martinsson At 11:38:55 AM On 08/15/2008 | - Website - |