hibernate-orm icon indicating copy to clipboard operation
hibernate-orm copied to clipboard

HHH-14228 Squash update into insert if possible

Open quaff opened this issue 5 years ago • 13 comments

save unnecessary update statements

https://hibernate.atlassian.net/browse/HHH-14228

quaff avatar Sep 27 '20 07:09 quaff

It seems better than https://github.com/hibernate/hibernate-orm/pull/3565

quaff avatar Sep 27 '20 07:09 quaff

seems great idea for optimization. not sure whether there is some unanticipated side effect (which we usually are aware of only after it has been released), though.

NathanQingyangXu avatar Sep 27 '20 13:09 NathanQingyangXu

Compare to #3567 , this one need call session.update(), which one is better? @NathanQingyangXu

quaff avatar Sep 29 '20 01:09 quaff

TBH, I am not sure,:). I am not familiar with action queue related stuff. Maybe Beikov knows much better than me.

On Mon., Sep. 28, 2020, 21:20 Yanming Zhou, [email protected] wrote:

Compare to #3567 https://github.com/hibernate/hibernate-orm/pull/3567 , which one is better? @NathanQingyangXu https://github.com/NathanQingyangXu

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hibernate/hibernate-orm/pull/3566#issuecomment-700367836, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6UYARHUQEW7VCP4OVJS3DSIEY6ZANCNFSM4R3MYANA .

NathanQingyangXu avatar Sep 29 '20 02:09 NathanQingyangXu

TBH, I am not sure,:). I am not familiar with action queue related stuff. Maybe Beikov knows much better than me. On Mon., Sep. 28, 2020, 21:20 Yanming Zhou, @.***> wrote: Compare to #3567 <#3567> , which one is better? @NathanQingyangXu https://github.com/NathanQingyangXu — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#3566 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6UYARHUQEW7VCP4OVJS3DSIEY6ZANCNFSM4R3MYANA .

@beikov What do you think?

quaff avatar Sep 29 '20 02:09 quaff

I don't know much about the ActionQueue, but I think that there might be situations where an update must happen after an insert and the two should not be merged. Your logic completely ignores possible dependencies. I didn't give this much thought yet, but I think there are cases when you first want to write null to a column in an insert and then update the column after some other insert to avoid violating a FK constraint.

beikov avatar Sep 29 '20 06:09 beikov

I don't know much about the ActionQueue, but I think that there might be situations where an update must happen after an insert and the two should not be merged. Your logic completely ignores possible dependencies. I didn't give this much thought yet, but I think there are cases when you first want to write null to a column in an insert and then update the column after some other insert to avoid violating a FK constraint.

I assume you think this one is better, It left to user, if they want merging then call session.update() or new method session.squash().

quaff avatar Sep 29 '20 06:09 quaff

BTW, I would highly recommend considering targeting this feature to v6 (wip/v6.0) for v6 is a natural testbed for such new features and @sebersole might provide invaluable feedback on the design. V5 is mainly for maintenance purpose and bug fixing.

NathanQingyangXu avatar Oct 01 '20 15:10 NathanQingyangXu

BTW, I would highly recommend considering targeting this feature to v6 (wip/v6.0) for v6 is a natural testbed for such new features and @sebersole might provide invaluable feedback on the design. V5 is mainly for maintenance purpose and bug fixing.

Rebased.

quaff avatar Oct 09 '20 00:10 quaff

BTW, I would highly recommend considering targeting this feature to v6 (wip/v6.0) for v6 is a natural testbed for such new features and @sebersole might provide invaluable feedback on the design. V5 is mainly for maintenance purpose and bug fixing.

Rebased.

Thanks. Let us see how @sebersole assesses this PR. BTW, the testing package in v6 is org/hibernate/orm/test. It is the testing cases migration target in v6 and CI building is based on it. Also, feel free to make use of new testing infrastructure abstraction in v6 (an example is org.hibernate.orm.test.entitygraph.EntityGraphFunctionalTests in the above package). Good luck!

NathanQingyangXu avatar Oct 09 '20 13:10 NathanQingyangXu

BTW, I used to doubt whether this fix would break ActionQueue's insert ordering. After manual cloning quaff's repo and running the latest testing cases (due to https://github.com/hibernate/hibernate-orm/pull/3581), I found his fix won't interfere with insert ordering.

NathanQingyangXu avatar Oct 14 '20 13:10 NathanQingyangXu

@gavinking I'm sorry to disturb you, I assume you are expert of ActionQueque, could you evaluate the value of this feature and review the PR?

quaff avatar May 09 '24 04:05 quaff

I assume you are expert of ActionQueque

Not anymore, no.

gavinking avatar May 09 '24 09:05 gavinking