Closed mamazu closed 1 year ago
@dbu Could you have a look at this? This could be a big performance improvement for everyone trying to delete properties.
it seems that phpstan sees some unhandled edge cases. can you please cover those? and run the cs fixer?
I fixed the errors phpstan reported, they were actually bugs. But now it should be clean maybe cs is still broken 'cause I tried to fix it manually.
Furthermore: Should I rebase this PR to 1.x and then upmerge it? Because I think projects like sulu/sulu could really benefit from that right now.
Furthermore: Should I rebase this PR to 1.x and then upmerge it? Because I think projects like sulu/sulu could really benefit from that right now.
is deleting several properties a pattern that comes up a lot in sulu? i would honestly prefer to have the change in the new major version, to favor stability over performance improvements - there is the off-chance that there is some side effect in this refactoring. and 2.0 should be released soon :tm: i already tagged the first beta release of jackalope/jackalope
looks good to me :+1:
can you please fix the remaining CS complaints and add an entry in the changelog for 2.0?
thanks a lot!
is deleting several properties a pattern that comes up a lot in Sulu?
It doesn't occur at all in Sulu yet. I could speculate that the previously bad performance might be a reason, but I am working on commands to clean the phpcr repository in Sulu and there a well performing delete is necessary for this.
But I guess 2.0 could be also a good idea in case any changes are BC breaks.
there should be no BC breaks, but it is a bigger change in the logic that i feel more comfortable as releasing with 2.0.0. consumers are expected to test new major versions more thoroughly than minor releases.
Why
Currently the implementation for deleting a list of properties is to iterate over them and treat every delete of a property separately. This is a real determent to the performance of PHPCR, especially with bigger nodes.
Example: I want do delete three properties from the same node in the database. For every property we want to delete this is what it does:
The solution
Instead of defining the batch delete as a list of single deletes why not have the single delete make a batch delete with one element.
This pull request extracts out the logic for deleting a property from a node and extends it that you can delete a list of properties on one node as well.
To illustrate this with the same example: This would be the steps the program takes:
Drawbacks
The new "batching functionality" first creates a map of properties and nodes to delete. Creating this map takes more memory than the brute force approach before.
Others
Maybe we could also backport this speed up the 1.x branch so that project which are currently using the jackalope doctrine adapter also get the speed up.