Norbert Wirges (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMGY4YjBlYzIw...
) / Improvement (
https://hibernate.atlassian.net/browse/HHH-16907?atlOrigin=eyJpIjoiMGY4Yj...
) HHH-16907 (
https://hibernate.atlassian.net/browse/HHH-16907?atlOrigin=eyJpIjoiMGY4Yj...
) Improve performance of flushing (
https://hibernate.atlassian.net/browse/HHH-16907?atlOrigin=eyJpIjoiMGY4Yj...
)
Issue Type: Improvement Affects Versions: 5.6 Assignee: Unassigned Components:
hibernate-core Created: 06/Jul/2023 08:11 AM Priority: Major Reporter: Norbert Wirges (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
)
We found flushes to still be slow even when using a CustomEntityDirtinessStrategy and even
if no changes need to be flushed.
In these cases it seems Hibernate still reads every field of every ( ? ) entity in the
session to verify possible 1:1 orphan removals in Cascade.cascade() here Cascade.java#L183
(
https://github.com/hibernate/hibernate-orm/blob/2fd6f548e4f935520f85ac85b...
). In most cases the value will simply be discarded, because the type check
isLogicalOneToOne() will be false anyway.
It looks as if this cost could easily be avoided by moving
if ( isLogicalOneToOne( type ) )
from inside cascadeLogicalOneToOneOrphanRemoval() to before / around the call to
cascadeLogicalOneToOneOrphanRemoval()
for both callers, which would avoid the eager reading of all fields for every flush.
Example stack of the unnecessary field reading:
PojoEntityTuplizer(AbstractEntityTuplizer).getPropertyValue(Object, int) line: 610
SingleTableEntityPersister(AbstractEntityPersister).getPropertyValue(Object, int) line:
5294
Cascade.cascade(CascadingAction, CascadePoint, EventSource, EntityPersister, Object,
Object) line: 184
DefaultPersistOnFlushEventListener(AbstractSaveEventListener).cascadeBeforeSave(EventSource,
EntityPersister, Object, Object) line: 426
DefaultPersistOnFlushEventListener(DefaultPersistEventListener).justCascade(Map,
EventSource, Object, EntityPersister) line: 167
DefaultPersistOnFlushEventListener(DefaultPersistEventListener).entityIsPersistent(PersistEvent,
Map) line: 160
DefaultPersistOnFlushEventListener(DefaultPersistEventListener).onPersist(PersistEvent,
Map) line: 124
1800883780.applyEventToListener(Object, Object, Object) line: not available
EventListenerGroupImpl<T>.fireEventOnEachListener(U, X,
EventActionWithParameter<T,U,X>) line: 118
SessionImpl.persistOnFlush(String, Object, Map) line: 801
CascadingActions$8.cascade(EventSource, Object, String, Object, boolean) line: 341
Cascade.cascadeToOne(CascadingAction, EventSource, Object, Object, Type, CascadeStyle,
Object, boolean) line: 510
Cascade.cascadeAssociation(CascadingAction, CascadePoint, EventSource,
List<String>, Object, Object, Type, CascadeStyle, Object, boolean) line: 434
Cascade.cascadeProperty(CascadingAction, CascadePoint, EventSource, List<String>,
Object, Object, Type, CascadeStyle, String, Object, boolean) line: 220
Cascade.cascade(CascadingAction, CascadePoint, EventSource, EntityPersister, Object,
Object) line: 153
DefaultAutoFlushEventListener(AbstractFlushingEventListener).cascadeOnFlush(EventSource,
EntityPersister, Object, Object) line: 159
DefaultAutoFlushEventListener(AbstractFlushingEventListener).prepareEntityFlushes(EventSource,
PersistenceContext) line: 149
DefaultAutoFlushEventListener(AbstractFlushingEventListener).flushEverythingToExecutions(FlushEvent)
line: 82
DefaultAutoFlushEventListener.onAutoFlush(AutoFlushEvent) line: 50
2018732354.accept(Object, Object) line: not available
EventListenerGroupImpl<T>.fireEventOnEachListener(U, BiConsumer<T,U>) line:
107
SessionImpl.autoFlushIfRequired(Set) line: 1372
SessionImpl.list(String, QueryParameters) line: 1452
QueryImpl<R>(AbstractProducedQuery<R>).doList() line: 1649
...
(
https://hibernate.atlassian.net/browse/HHH-16907#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16907#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100230- sha1:e339e49 )