Should you ever use view name instead of view alias with GetView / @DbLookup?
Jamie Magee January 19 2011 10:24:24 AM
Question: I read Jamie's article about using the view name and not the alias for faster performance. However, a manager I work with has stated the IBM and several other places ie, notesninga's and the such say ALWAYS use an alias. I was wondering why you would state otherwise. My personal preference is not to use an alias, I had made the suggestion here based on your article. Thanks, JohnHi John,
Thanks for writing! The recommendation to use the view name is in cases where you have many (e.g., hundreds) of views, AND if the performance of the lookup is slow between a Notes client and Domino. This is because Domino scans to find the view in the design list first using the view name, then the view alias, then a case-insensitive view name, then case-insensitive on the alias. So if you have 200 views in your design, a db.GetView or dblookup from a Notes client to a Domino server using a case-insensitive phrasing of the view alias will take 600-800 visits through the design list before it finds the view. Using the case sensitive name of the view will only have to scan a maximum 200 design entries. The difference for hundreds of views can be on the order of a second or so on a typical environment. Not a large amount of time in some scenarios, but can be worth gaining in others.
The downside is that if you change the name of the view (e.g., the name that you want Notes client users to see in the view list), you will also need to change it in your code. But most apps these days use Outlines or navigators for view selection, so you would not need to change the name of a view for business requirements purposes. And even if you did, you could use Design Synopsis or a 3rd party tool to find and change all instances of a view name.
Thanks for the question and giving us a chance to clarify our tip!
Jamie
- Comments [1]