PermaLinkCustom seaching (the fast way)09:41:55 AM
Written By : Scott Good

It's been a while since I last posted a Show-N-Tell Thursday item (and, yes, I know today's not Thursday but, well, whatever). Jim Sanders, one of our guys, came up with some really interesting numbers related to what is the fastest way to do custom searching of a Notes database with LotusScript. Below are Jim's findings...enjoy:

Recently a client has had the need to do a custom search routine in an existing Notes database. You've seen the kind where you build a dialog box which allows a user to choose various conditions they want to search for. Typically it runs something like this:

  1. Prompt the user for what they want to retrieve.
  2. Run the search using either the database Search or FTSearch methods.
  3. Display the results.

Not a big deal until you need to also add on a custom export (say through Excel) in which you need to organize this lump of data into some criteria that has been predefined by the client. We all know that Search and FTSearch return (essentially) an unordered document collection. There are numerous ways of doing that kind of sorting. Heck, Teamwork has one built into a standard script library (TSFormulas) that we nearly always use. This library contains both our own document collection sorting routine as well as a lot of @Formula code re-written into script and some other cool stuff thrown in for good measure.

However, since we couldn't use that TSFormulas script library we were stuck coming up with a way to do this sort. The senior developer at the client was interested in using a sorted document collection object he'd pulled off the net a while back. My idea was to dump the entire document collection into a folder (using the handy little PutAllInFolder method of the DocumentCollection object) and let the folder do the sorting for us. Since we're interested in keeping performance as fast as possible we did a head to head comparison just to see who might come out on top. Using the same database and search criteria (returning 4,981 documents via the search) as our test bed and utilizing the new profiler capability of the R7 client we have a winner.

For the sorted document collection object we have the following results:


olumns
TestColSort Profile

07/17/2006 04:34:34 PM EDT
Elapsed time: 14621 msec
Methods profiled: 1
Total measured time: 7061 msec
ClassMethodOperationCallsTime
DocumentCollectionGetNextDocument49815779
DatabaseSearch1691
DocumentGetItemValue4981591
ViewColumnFormulaGet50
ViewColumnIsSortedGet30
DocumentCollectionCountGet20
DatabaseGetView10
SessionCurrentDatabaseGet10
ViewGet10
DocumentCollectionGetFirstDocument10
ViewColumnItemNameGet10

Not bad, but it's getting to the point where users will get a little impatient. The folder sort method give us the following:


Test Folder Sort Profile

07/17/2006 04:28:49 PM EDT
Elapsed time: 3555 msec
Methods profiled: 5
Total measured time: 3545 msec
ClassMethodOperationCallsTime
DocumentCollectionPutAllInFolder12935
DatabaseSearch1610
DatabaseGetView10
SessionCurrentDatabaseGet10
ViewGetFirstDocument10

Better. Still not the greatest performer and we still have to do the Excel export, but not bad for a quick and dirty "custom" sort comparison. The sorted collection object is basically using the same "method" for determining the sort order as the folder sort option. It reads in a view design and sorts the collection according to the columns in the view. Both the folder and the view used in these tests have the same structure... I built my sort folder from the design of the view used by the sort object.

This test didn't go any further than trying to determine which is the faster method of sorting. It's interesting to see that the view indexer (even locally) runs faster than processing a series of document references that are already in memory. We'll probably attempt a similar test in the future where we have the code spin through the entire collection and access each document to see if there is any degradation of the folder's advantage once you start having to get handles to all the documents in the two collections. But, that's waiting for another day.

If you're really curious about the details, go here.

Comments :v

1. Stephen Hood07/25/2006 02:15:52 PM


Scott, make sure you take into account the time it takes to REMOVE the items from the folder to get it ready for the next time it's populated. There isn't a folder.empty so it means getting all entries and using removefromfolder. On large collections I think that can take the bulk of your time vs the putinfolder. Then again maybe I've overlooked something - it was awhile ago that stuff was written.

I just remember wishing there was a Folder.empty that "quickly" zeroed out the items. There was something similar in the old paradox days - one function zeroed out the indexes and one deleted each row. The zero function was instantaneous and the delete was ..well much slower.




2. David Leedy07/26/2006 08:51:37 AM


In the old days of 4.6 and early 5 I used to use Folders as a kind of Dynamic view for an application that had 75 remote users. This started before show single category came to be. Anyway, we started having server crashes all the time. Eventally Lotus flew some people out to see what was going on and they found that putting lots of docs in a folder and removing them overloaded something in their folder structure. The number of users and also replication may have been an additional factor, I forget. I think I re-wrote the app to use show-single-cat.

This has probably been fixed by now but be aware that there once was a problem pumping tons of docs in a folder, removing them and doing it again.

I also seem to recall the remove of the documents took a while..




3. Volker Mannherz07/28/2006 06:17:25 AM


Scott, did you ever tried sorting a DocCollection using den SortedCollection class from bookmark.nsf (and others) ?
I actually have no 7.x Client installed, so profiling would be quite difficult...




4. Tim Crannigan09/07/2006 07:08:12 AM


Scott

Maybe I am missing something, but why not sort them once they are in Excel - that is bound to be quicker. (I assume you are using ole to export to excel)?

Regards




Enter Comments^


Email addresses provided are not made available on this site.





You can use UUB Code in your posts.

[b]bold[/b]  [i]italic[/i]  [u]underline[/u]  [s]strikethrough[/s]

URL's will be automatically converted to Links


:-) :cry: :-\ :huh: ;-) :cool: :grin: :emb: :laugh: :-p :lips: :-( :rolleyes: :-o :-D :angry: :-x
bold italic underline Strikethrough





Remember me    

Disclaimer & Copyright
Monthly Archive
Contact me...
Racing sponsors and such...

Thank you sponsors!

GABlogLogo.jpg

GOODAero

GOODAero specializes in building aerodynamic products for racing cars. Our first product, the GOODAero Raptor wing is available at a surprisingly reasonable price (under a grand) for a full carbon, full-sized, racing wing. Check it out.


Infinite Fiberworks Co, a great source for high-quality Porsche fiberglass parts

Infinite Fiberworks Co.

If you are looking for fiberglass for Porsches, IFC is the place to go. I have used parts from most of the major suppliers and IFC's are easily the highest quality and the most reasonably-priced. Contact Mike at Infinite Fiberworks for more information.

Located in Racine, OH (so far Southeast they're almost in West Virginia), IFC's goal is to be The Best. Give 'em a try.


Bent or ugly wheels? Call Wheel Medic!

Wheel Medic & The Round House

Whether you need to repair, repaint, refinish or just replace your wheels, the guys at Wheel Medic/Round House can get you back on the road in no time!

Wheel Medic, Inc is a family-owned company which specializes in the repair and restoration of aluminum wheels.

The Round House was founded to service Wheel Medic's clients looking for more than just repair work...from custom wheel colors to high-end wheel applications and body kits, the Round House is there to serve the discriminating automotive enthusiast.


Used Porsche parts, great prices!

A Part Above

Looking for used parts for 944s, 924s, 968s or other late-model water-cooled Porsches? Contact John at A Part Above.

Located in Strongsville, OH (20 miles south of Cleveland) their goal is to provide top quality parts and services. I can tell you, John is great to work with and the prices? Very hard to beat.


SMRT Motorsports wants you!

SMRT (that's short for Skid Mark Racing Team), a very-

loosely organized band of fun-loving friends who enjoy auto racing (heck, cars in general), and the occasional adult beverage, wants you to be a part of our team.

Go here to find cool T-shirts, sweatshirts, caps and mugs with the SMRT team logo.

The BlogRoll
Lotus Domino ND6 RSS News Feed RSS Comments Feed Geo URL RSS Validator Blog Admin Lotus Geek Open Notes Picture Database OpenNTF BlogSphere
Calendar
February 2012
Su
Mo
Tu
We
Th
Fr
Sa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
By Category
What I do for a living


I am the President of Teamwork Solutions a long-time Lotus, now IBM, Premier Partner.

With offices in Columbus and Cincinnati, Ohio, we specialize in custom application development for IBM Lotus Notes, Domino, and related technologies. Our software product, ProcessIt! (see below), is quite possibly the world's best, most powerful and easiest-to-use workflow tool for Notes and the web.

Our clients are some of the world's largest corporations along with others that aren't so big.

We do excellent work, quickly, and often on a fixed-fee basis. We'd love to talk to you about your next project.




I am a Contributing Author to Lotus Advisor Magazine, with more than 40 articles under my belt.

I've written how-to series (serieses?) on LotusScript, JavaScript, Cascading Style Sheets (CSS), and now, AJAX (Asynchronous JavaScript and XML), as well as a bit on miscellaneous web development topics.


TheView.jpg

I also write for The View as of the July/August issue where I showed how to take an ugly Notes applications and make it beautiful with just a few minutes' (careful) work.



I am the chief architect and one of two primary developers for what many consider the best all-around workflow tool for Notes/Domino, anywhere, regardless of price.

It's called ProcessIt!, and you can read all about it at www.notesworkflow.com but the bottom line is this: ProcessIt! is fast and easy to learn, extremely powerful, and can be used by mortals. Even--dare I say it?--common users.

You can spend a lot more on a workflow tool but you won't be able to do a lot more for all the extra money.

Don't believe me? Download and try it for free for 60 days.



GTSLogoSm.gif
Copyright Porsche and NASA...not me!

I race a Porsche 944 S2 in National Auto Sport Assocation events and am the 2008 National Champion in NASA's GTS2 class.

Blame this event, a few years ago, for starting that particular money drain all over again.

In support of my habit, I am the NASA Great Lakes Region's GTS (German Touring Series) Director.

I'm also a Nationally-Certified Instructor for the Porsche Club of America and am in charge of classroom sessions for the Mid-Ohio region when we are doing high performance driving events.

In a prior racing life, I was the Midwestern Regional Formula Atlantic Champion and, in 1991, the Ohio Vally Region of SCCA's Regional Driver of the Year (but that, alas, went away when my credit cards let go of the rope!).




I'm writing a book...or at least trying to.

It's murder mystery in which, not too surprisingly, the main character runs a small software company and races cars for fun. Oh yeah, and lives near where I do.

Just where do they come up with these crazy ideas?

Facebook