Optimization issue

Hello everibody,

I’m concerned about the perfomance of an application that i’m about to deploy.

I’m the application, i have got to delete certain documents using an action button. The issue is that i have to delete that documents that contain a certain ID and that are interrelated (similar to a DELETE cascade in sql). Right now i’m looping through db.alldocuments checking if each document matches the condition. I fear this algorithm will get slower as the db grows, so i’m thinking of alternatives:

  • Use a db.FTSearch and loop through the documentcollection

  • Use getFirstDocument(key) from notesView

  • Create a categorized view(by ID) and loop through the docs.

  • Agents?..

I do some doc updates in the same way i delete, so the solution can apply to diferent areas of my db.

Can you tell me which one is better approach? Can you provide better solutions?

Thank you in advance!

Sergi Menéndez

Subject: Optimization issue

It depends on how you interrelate documents.

I would use “view.GetDocumentByKey(key, True)” or “view.GetAllEntriesByKey(key)”. “view.CreateViewNavFromCategory(key)” method can also be interesting.

Subject: RE: Optimization issue

Thanks,

I’ve read about this methods, but i’m afraid i’ll have to do some experiments to see which one is better.

Thank you very much

Sergi Menendez

Subject: Optimization issue

Hi Sergi,

I did something similar. The original agent was using an db.Search but it was really slow as the db was bigger

So I’ve changed the code to something like that

Key = Number + Name + Date

Set doc = view.GetDocumentByKey( Key )

For a database of 175 000 documents(My view have 15 000 parent documents), it went from more than a minute to 1 to 4 seconds.

A major improvment in speed and the network team was really happy (From megs to Ko)

JYR

Quebec,Canada

Subject: RE: Optimization issue

That’s great! The problem lies in that I need a subset of document instead of a single document that match a criteria.

I did some experiments(with not so many docs, cause my db in not that large), by the way, and here are the results in case someone’s interested:

Searching across 5000 docs (where about 100 match the criteria and require looping), on an indexed database(server and client on the same machine, PIII 600Mhz 384Mb ram, winXP), using:

  • db.alldocuments + conditional IF to check condition:

22 seconds aprox

  • view.getAlldocumentsByKey(criteria)

1 second aprox

  • db.FTSearch(criteria)

1 second aprox

With this amount of docs, i can’t see the difference between the 2 last methods. I think I’ll follow your advice and use view.getAllDocumentsByKey because views are always indexed, and I don’t always get the expected results from FTSearch.

Thanks for your interest!

Sergi Menendez