Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-414

Improve Performance of onUpdate Event Listeners

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-ALPHA4
    • Fix Version/s: 2.0-BETA1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      Currently both onUpdate lifecycle events and event listeners trigger the recomputeEntityChangeSets method.

      I would suggest to change the event listeners to only recieve a reference of the changeset and not computing the differences for each affected entity. This could improve performance considerably in the onUpdate event case and would be more helpful for users to understand how limited the onUpdate event listener really is.

      1. ddc414.patch
        7 kB
        Benjamin Eberlei

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Another valid approach would be to require an explicit call to recomputeEntityChangeSets from an onUpdate listener.

        I think both use-cases could be supported.

        Show
        Benjamin Eberlei added a comment - Another valid approach would be to require an explicit call to recomputeEntityChangeSets from an onUpdate listener. I think both use-cases could be supported.
        Hide
        Benjamin Eberlei added a comment -

        This would be a BC break, so implementation before Beta 1 seems a necessary must

        Show
        Benjamin Eberlei added a comment - This would be a BC break, so implementation before Beta 1 seems a necessary must
        Hide
        Roman S. Borschel added a comment -

        Well, ok, we can still have BC breaks during BETA though, only once we hit RC the API is frozen.

        Show
        Roman S. Borschel added a comment - Well, ok, we can still have BC breaks during BETA though, only once we hit RC the API is frozen.
        Hide
        Benjamin Eberlei added a comment -

        Attached is a proposed implementation example

        Show
        Benjamin Eberlei added a comment - Attached is a proposed implementation example
        Hide
        Benjamin Eberlei added a comment -

        Implemented, notes in UPGRADE_TO_2_0:

        ## Change of PreUpdate Event Listener
        
        Event Listeners listening to the 'preUpdate' event can only affect the primitive values of entity changesets
        by using the API on the `PreUpdateEventArgs` instance passed to the preUpdate listener method. Any changes
        to the state of the entitys properties won't affect the database UPDATE statement anymore. This gives drastic
        performance benefits for the preUpdate event.
        
        Show
        Benjamin Eberlei added a comment - Implemented, notes in UPGRADE_TO_2_0: ## Change of PreUpdate Event Listener Event Listeners listening to the 'preUpdate' event can only affect the primitive values of entity changesets by using the API on the `PreUpdateEventArgs` instance passed to the preUpdate listener method. Any changes to the state of the entitys properties won't affect the database UPDATE statement anymore. This gives drastic performance benefits for the preUpdate event.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Benjamin Eberlei
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: