I herwith suggest to have a new LS-command: NotesView. Search
It should be similar like Notesdatabase.Search, but should only work on the view content. I know that db.search has the reputation to be slow, but if it would only work in a view it could be fast and very efficent dependend on what you want todo. Here is why:
It has several advantages if users are connect to the server over lines with a high latency. The search is executed on the server and only sends a NotesCollection (a bag of document references ) in one go to the client and not every single document (and all the document data) and you have to add up the latency for each document.
With this collection one can now use of the Collection commands like Subtract, Merge, Intersect, MarkAllRead, Markallunread, etc. They are also defined for the NotesViewEntrycollection and if needed, you can turn the NotesDocumentcollection into a NotesviewentryCollection by merging an empty NotesViewEntryCollection with your NotesDocumentCollection.
You can find a discussion under the topic "LS command NotesCollection.RemoveAlll is pretty slow" in the Notes/Domino community forum. This discussion lead to this idea and the below fast code.
Example:
I had to delete all email documents in a view that are older than today.
Now the below code beats the original sequential read and delete method on my computer over VPN and on our Dev Server by a factor of up to 10. Of course these measurements depend on the latency/VPN and the workload of the server. If the server is at its limits, it most probably will be also less fast and if you are in the companies LAN you also will not gain such an acceleration . But very good for home office !
t$=Date$ +" 23:59:59"
Dim dt As New NotesDateTime(t$)
Call dt.Adjustday(-1, true)
formula$={form = "Memo":"Reply"}
Set coll=db.Search(Formula, dt, 0)
Set ecoll=view.Allentries
ecoll.Subtract coll
ecoll.Removeall(false)
Call ws.ViewRefresh
Print "It took " & (GetThreadInfo(6)-st1&) & " msec"
Db.search is fast if one only wants to search the new documents which were created/received today. One hast to set the Notesdatetime value accordingly.
Jochen "Joe" Herrmann
Have also forgotten to mention, that this command could also run on a client only (no server) environment. So no separate code for server and client.
Well, the view.search would make the LS language more complete and would allow to do certain tasks faster without leaving the LS environment. And as the command/code already exists in the form of DB.search it would be fast and inexpensive to implement it.
And, as most of the developers don't use Java, it could be very fast used in new and existing LS projects. No learning curve, most developers know this command, The syntax of the query is known and can be easily used.
Anyway, so interesting times ahead with DQL. When will a stable version be expected ? Had not had the time to look into it. Can it be used in LS or only JNA?
Jochen "Joe" Herrmann
What you are asking for is nowadays possible with DQL's IN and IN ALL search expressions, e.g.
https://help.hcltechsw.com/dom_designer/10.0.1/basic/dql_inall.html
which should have pretty good performance, because additional search terms are probably only run on the note ids of the view index as intermediate result.
Have you tried these? I think they only work on local databases in the client or server in 12.0.0. Not sure if they will be remoted in 12.0.1.
Using Domino JNA, you can get all ids of a view with
//open DB as ID user:
NotesDatabase db = new NotesDatabase("Server/Org", "path/to/db.nsf", "");
NotesCollection view = db.openCollectionByName("MyView1");
NotesIDTable retIdTable = new NotesIDTable();
view.getAllIds(Navigate.NEXT, false, retIdTable);
in no time, because that call just copies an internal existing IDTable (so no reader rights check here), as long as you have the response hierarchy flag of the view disabled.
And the NotesSearch class has search methods to run a formula search just on that IDTable, not on the whole database.
https://github.com/klehmann/domino-jna/blob/master/domino-jna/src/main/java/com/mindoo/domino/jna/NotesSearch.java
And it's even possible to let it compute values from the document's summary buffer and do the search incrementally.
Karsten Lehmann, Mindoo
We love these well written ideas! *thumbsup*