Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue when finding changes by instanceId with ChildValueObject #1039

Closed
gravity-57 opened this issue Dec 4, 2020 · 5 comments
Closed
Labels

Comments

@gravity-57
Copy link

I use Javers (5.12.0) with MongoDB repository in a production environment for auditing one object with one child.
Currently the snapshots collection contains more than 1 millions documents and we meet performance issue when finding changes by instanceId with child value object :

QueryBuilder queryBuilder = QueryBuilder.byInstanceId(orderId,OrderAudit.class).withNewObjectChanges().withChildValueObjects(); Changes changes = javers.findChanges(queryBuilder.build());

This request takes about 4 seconds to get results.

After debugging,it appears that "withChildValueObjects()" option will generate a regex filter in MongoRepository to retreive child objects:

{"find": "jv_snapshots", "filter": {"$or": [{"globalId_key": "OrderAudit/1818342"}, {"globalId_key": {"$regularExpression": {"pattern": "^OrderAudit/1818342#.*", "options": ""}}}]}, "sort": {"commitMetadata.id": -1}, "limit": 100, "$db": "javers-audit"}

As we can see the query do a filter on exact globalId_key ( very fast as there is an index for this property in Mongo DB ) but the second part with regex filter is very slow.

Have you already see this issue ?
Is there any solution to solve this ?

May be we could filter using globalID.ownerId property ?

"globalId": { "valueObject": "OrderAuditChild", "ownerId": { "entity": "OrderAudit", "cdoId": 1818031 }, "fragment": "child" }

Thanks in advance for your help :)

BR

@bartoszwalacik
Copy link
Member

Hi, since you are close to the solution of this issue, please contribute a PR

@gravity-57
Copy link
Author

Hi,

I implemented a fix for this performance issue on a local branch. When I tried to push it, I received a permission denied. Miss I something ?
It is the first time I contribute to an open source project so I am not aware of all good practices.

BR

@bartoszwalacik
Copy link
Member

Ok, so the standard flow on github looks like that :
you need to fork this repository and create a PR from your fork's branch to this master

for example #1021

@vladimirmutafov
Copy link
Contributor

Hi! Me and my team hit this problem too with a DocumentDB collection with around 4 million objects. I've tried to fix this with #1367 @bartoszwalacik could you please take a look?

@bartoszwalacik
Copy link
Member

Fixed in 7.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants