Discussion: What technique is faster?
Category What do you think?
Bookmark :
I was helping out another group with some performance tuning on a large Notes application. There are amy areas we discussed, but one suggestion I gave was interesting. there were multiple NOCACHE DBLookups to the same view, but returning different values. All lookups returned a single document's worth of values, and the view itself contained less than 100 documents; however the overall database contains over 2GB of documents. All lookups are in the same db containing the data. I suggested concatenating the values into a single column, and then retrieve those values, parse them, and use them - the normal stuff we always recommend.
For instance - let's say you have 5 (sets of) values you need to return from a view. 3 are single values, while to are actually small lists of values. You concatenate these values into a single string in a column in the view:
Val1 + "~" + Val2 + "~" + Val3 + "~" + @Implode(Val4; "^") + "~" + @Implode(Val5; "^")
This single column is used in a single lookup in a hidden field called ValueList. Then, you simply use @Word against ValueList in the target fields to parse and retrieve these values as needed. The formulas used to get a particular value in these target fields would be:
Val1 == @Word(ValueList; "~"; 1)
Val2 == @Word(ValueList; "~"; 2)
Val3 == @Word(ValueList; "~"; 3)
Val4 == @Explode(@Word(ValueList; "~"; 4); "^")
Val5 == @Explode(@Word(ValueList; "~"; 5); "^")
Pretty straightforward stuff.
But here's the rub: When the developer implemented this particular recommendation he reported that it was actually slower than the old method of doing multiple NOCACHE lookups to the view. That surprised me.
I guess I can see that there is a "cost" for parsing the strings - but would that be slower than the lookups? Where is the break-even point? Where does the concatenated/parsing technique actually perform better than the lookup of individual values technique?
I would be curious to see if anyone else has tested things like this, or has any supporting evidence either way. I'd really be interested in hearing some real-world scenarios and results, not just "should work this way", or anectdotal evidence.
What do you folks think? What is your experience?
Rock
**If you've got melted chocolate all over your hands, you're eating it too slowly.







Blog Roll









Comments
Saw your post and thought I would try some amateur testing of my own. I found that your suspicions were correct - your technique improves the performance of this functionality greatly. You can check the results at the URL below!
{ Link }
Andrew.
Posted by Andrew Culbert At 10:51:03 AM On 11/13/2006 | - Website - |
Posted by Jens At 05:09:53 PM On 11/08/2006 | - Website - |
Posted by Miha Vitorovic At 04:46:19 AM On 11/09/2006 | - Website - |
Posted by Axel Janssen At 03:01:54 PM On 11/09/2006 | - Website - |
Posted by Carl At 03:05:18 PM On 11/10/2006 | - Website - |
So, I can't offer any illumination, other than I don't notice any particular performance "hit" exploding one string (versus doing look-ups). I'd be surprised if look-ups were quicker, I must confess.
Posted by Ben Poole At 03:12:14 PM On 11/08/2006 | - Website - |
Also, I think the biggest advantage to this technique is not to be gained in the initial document lookup; but instead to subsequent lookups. The information is maintained in (and therefore pulled from) the cached view's index, rather than actually pulling from the doc itself.
I would be very suprised to discover that subsequent calls anything other than much faster as compared to the initial method.
-Devin.
Posted by Devin Olson At 06:58:01 PM On 11/08/2006 | - Website - |
Posted by Charles Robinson At 12:16:01 PM On 11/09/2006 | - Website - |
Internally, time values are more resolute than 1 sec.
Rock... is the view column doing the collapsed string construction, or is it already a field on the doc being looked up?
Posted by Nathan T. Freeman At 07:02:06 PM On 11/08/2006 | - Website - |
Keith
Posted by Keith Strickland At 03:39:44 PM On 11/08/2006 | - Website - |
Posted by Alan Bell At 04:01:10 AM On 11/10/2006 | - Website - |
Posted by Richard Schwartz At 01:45:44 AM On 11/09/2006 | - Website - |
Posted by Charles Robinson At 05:48:05 PM On 11/08/2006 | - Website - |
Posted by Richard Shergold At 05:02:58 PM On 11/08/2006 | - Website - |
a) don't both with it, and let the cache do it's job.
b) try a named cache. @DbLookup("" : "Col1Cache" ; "" ; "Myview"......)
Posted by Andrew Pollack At 09:50:25 PM On 11/08/2006 | - Website - |
I did two additional tests.
First, I followed Carl's suggestion and went for a higher latency network...first I thought I would use the Internet to introduce latency, but I then figured that it would be to variable for testing purposes...then I remembered that my NIC would allow me to throttle the bandwidth and a I cut the connection down to 10Mbps (and I had to change my switch to support this.)
Low and behold, the expected performance difference appeared. Documents that were generating consistently in the 0.5 sec range, now take either 0.7 secs (one lookup/nine parsed strings) or 5.8 secs (nine independent lookups.)
The more profound effect is with the volume of network traffic generated by each scenario.
My very simple form with only one lookup generated 21 64K payload packets and an equal number of respondent ACKs from the client(as captured by an old copy of Ethereal.) The nine lookup version of the form generated 243 64K payload packets and an equal number of ACKs from the client.
Then I got creative and turned off network encryption and compression on both the client and the server. The first test generated 70 packets, the second over 800 packets.
I am still looking for an R5 client disk to try this again (I found a server disk
So, use network compression and make as few lookups as possible by exploiting the one lookup/multiple parsed strings technique (also don't rely on anecdotal evidence go for the empirical stuff - and don't forget to reset your NIC and switch back to 1Gbps
Posted by andy broyles At 06:45:27 PM On 11/10/2006 | - Website - |
In the Global Declarations I created a variable named 'starttime' of datatype single. In Global Initialize, I set the value of 'starttime' to Timer() (a LS timer function value.) Next in the form's PostOpen, I use a Print timer() - starttime to printout the elasped time of the generation of the form.
With the testing harness in place, I tested a variety of scenarios that touch this topic...cached & nocache & recache single lookups/nine parsed strings as well as cached & nocache & recache nine lookups/no parsing.
To my surprise there was only slight variations (less than 0.08 seconds max on form loads that took a total of ~0.5 seconds) in elapsed times. The server isn't highly tasked and the network I am running across is 1GB duplexed switched.
If I remember correctly, in either 6 or 6.5 there were major changes in Notes' network layer to make Notes less 'chatty'. Could it be that the client is 'packaging' the nine multiple lookups transporting them to the server, the server processing the requests serially, then packaging the nine responses back up and sending them back across the network to the client? If so, then the problem of the network layer slowing things down would be explained. I think I have an R5 disk around somewhere to test this.
Posted by andy b At 08:03:25 AM On 11/10/2006 | - Website - |