Uploaded image for project: 'Doctrine 2 - ORM'
  1. Doctrine 2 - ORM
  2. DDC-414

Improve Performance of onUpdate Event Listeners

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: 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
        beberlei 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
        beberlei 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
        beberlei Benjamin Eberlei added a comment -

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

        Show
        beberlei Benjamin Eberlei added a comment - This would be a BC break, so implementation before Beta 1 seems a necessary must
        Hide
        romanb 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
        romanb 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
        beberlei Benjamin Eberlei added a comment -

        Attached is a proposed implementation example

        Show
        beberlei Benjamin Eberlei added a comment - Attached is a proposed implementation example
        Hide
        beberlei 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
        beberlei 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:
            beberlei Benjamin Eberlei
            Reporter:
            beberlei Benjamin Eberlei
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: