please don´t ask me why i do something like that . It´s because we had to do it that way
Ok, here´s the problem.
We have a database that shows certain informations calculated out of data of other databases. Because we can´t calculate the daily differences we do the whole thing every day (scheduled agent). That means we delete all docs in the “results database” and build it up from the scratch day by day.
At the moment we do it by db.alldocuments.removeAll(). That takes about 1-1,5h and that´s not really fast.
Is there a “API”-way to do it faster?.. (without deletion-stubs)
Is there any reason why you can’t delete the whole database and recreate it from a template? The biggest problem would be replicas, but if you can work around that, deleting the database and recreating it might be faster. You could also arrange it so that the results database does not have to be a fixed name, and create a blank one to use on demand, cleaning up the old one’s asynchronously.
yes, the replication would be a problem, when i´d delete the whole database every day. Because the database is indexed in a special application database index i can´t just rename it or let a change of the replicaID happen.
I´d prefer deleting all docs every day, though i´m aware of the fact, that with Script there is no fast way to accomplish that.
Don´t anyone know.
is there a way to get all documents of a db in a ID Table so i can pass it to the API Function NSFDbDeleteNotes ?
Not sure why using script is so slow in your case. Have a look at NSFSearch in c-api reference. There’s an example that get’s you an id table which you can then pass to NSFDbDeleteNotes.
Calling api calls from script can be tricky, but it can be done.
I wouldn’t delete and add all documents every time you update the database. Instead take a look at the NotesDatabase.Search method, and use the CutOffDateTime parameter to update only documents since the last date/time you did the update.
I think he can not use this approach as his data is the result of calculations/aggregation from other dbs, so he has to update/replace always all documents – the differences are on field level – or sometimes probably the docs have to be deleted. With some effort it could all be figured out, but it’s possibly not worth it.
Julian, you could delete docs without leaving deletion stub (should be fine unless your data gets replicated). I think I even posted once a code here (or was it in Notes 4-5 forum?). But the approach suggested by Kerr seems to be a better approach.
If you are really deleting all documents, make an empty replica copy and simply copy it over the top each night. It should take almost no time, and the database replicas will still work.