Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StatelessSession insertAll in batch does not do batching #2108

Open
s4iko opened this issue Feb 12, 2025 · 8 comments · May be fixed by #2132 or #2136
Open

StatelessSession insertAll in batch does not do batching #2108

s4iko opened this issue Feb 12, 2025 · 8 comments · May be fixed by #2132 or #2136
Assignees

Comments

@s4iko
Copy link

s4iko commented Feb 12, 2025

I tried the method insertAll(int batchSize, Object... entities) but it does not do batching to insert the entities, they are all inserted using a separated query.
I didn't find any documentation about insertAll.
Do I need to add some configuration to enable batching with StatelessSession ?
Do the dialect limit the use of the StatelessSession (mine is PostgreSQLDialect included in Hibernate core 6.6.6) ?

Thanks for your help :)

Quarkus: 3.18.2
Hibernate reactive: 2.4.4

@gavinking
Copy link
Member

but it does not do batching to insert the entities, they are all inserted using a separated query.

How did you make this determination?

Impossible to help you when you have not attached any sort of reproducer.

@DavideD
Copy link
Member

DavideD commented Feb 12, 2025

I've created a quick test and it actually seems something is not right: DavideD@d6a35be

@gavinking
Copy link
Member

But are you sure that the number of logged statements tells you anything about whether those statements are being batched or not?

I don't recall how it worked in reactive, but that's certainly not how it works in ORM.

@DavideD
Copy link
Member

DavideD commented Feb 12, 2025

The vert.x SQL client expects a query and a list of parameters, we log before calling the client, so checking the log should work for testing. The batch execution happens here:

return client().preparedQuery( sql ).executeBatch( parameters ).toCompletionStage()

I can also see that it works for the regular session, and that the batch options is skipped for some reason using the debugger.

@gavinking
Copy link
Member

OK, fine.

@gavinking
Copy link
Member

OK, @DavideD I believe I found the bug and have a fix.

@gavinking
Copy link
Member

OK, @DavideD I believe I found the bug and have a fix.

Or maybe not. Haha.

@DavideD
Copy link
Member

DavideD commented Feb 12, 2025

Or maybe not. Haha.

:) It happens to me all the time

@dreab8 dreab8 self-assigned this Feb 20, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 20, 2025
dreab8 pushed a commit to dreab8/hibernate-reactive that referenced this issue Feb 20, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 20, 2025
dreab8 pushed a commit to dreab8/hibernate-reactive that referenced this issue Feb 20, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 26, 2025
dreab8 pushed a commit to dreab8/hibernate-reactive that referenced this issue Feb 26, 2025
dreab8 added a commit to dreab8/hibernate-reactive that referenced this issue Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants