From: | Anthony Nowocien <anowocien(at)gmail(dot)com> |
---|---|
To: | CRUMEYROLLE Pierre <pierre(dot)crumeyrolle(at)c-s(dot)fr> |
Cc: | pgsql-fr-generale(at)lists(dot)postgresql(dot)org |
Subject: | Re: insert multi values limitations |
Date: | 2019-09-23 10:44:25 |
Message-ID: | CAH5RRoNFLNB3KPsvXC+ypXasoPXhCYUhFuTpoG5qzXiUVXppPQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-fr-generale |
Bonjour,
D'après
https://stackoverflow.com/questions/47664889/jdbc-batch-operations-understanding/48349524#48349524
*"It is smart enough to use 2 statements in order to insert 10 rows. The
first one is 8-valued statement, and the second one is 2-valued statement.
Usage of powers of two enables pgjdbc to keep the number of distinct
statements sane, and that improves performance as often-used statements are
server-prepared (see What's the life span of a PostgreSQL server-side
prepared statement
<https://stackoverflow.com/questions/32297503/whats-the-life-span-of-a-postgresql-server-side-prepared-statement/32300222#32300222>
)" *
Si tu souhaites envoyer exactement le nombre de valeurs précisées dans
batch_size, alors il faudra mettre une puissance de 2, sous peine de voir
l'INSERT splitté.
Anthony
On Mon, Sep 23, 2019, 11:24 CRUMEYROLLE Pierre <pierre(dot)crumeyrolle(at)c-s(dot)fr>
wrote:
>
> bonjour
>
> je teste une insertion multi valeurs via spring boot jpa hibernate jdbc ,
> en positionnant les paramètres suivants :
>
> spring.jpa.properties.hibernate.jdbc.batch_size=10
> reWriteBatchedInsereWriteBatchedInserts=true dans ma connexion jdbc
>
> spring.datasource.url=jdbc:postgresql://localhost:5432/postgres?reWriteBatchedInserts=true
>
> normalement ceci doit générer des insert multi valeurs par paquets de
> 10 => insert into mytable (id , data) values
> (1,),(,),(,),(,),(,),(,),(,),(,),(,),(10,)
>
> mais je constate que les insert multi values sont "splités" de la
> façon suivante
>
> insert into mytable (id , data) values (1,),(,),(,),(,),(,),(,),(,),(8,)
> insert into mytable (id , data) values (9,),(10,),
>
> il semblerait que le driver postgres split les insert multi values
> suivant des règles particulières
> et en effet je retombe dans le scénario décrit en fin de cette page =>
>
> https://vladmihalcea.com/postgresql-multi-row-insert-rewritebatchedinserts-property/
> qui dit "the PostgreSQL driver will split it into smaller ones to
> address TCP deadlock issues"
>
> quelqu'un peut il me donner une petite explication confirmation sur ce
> comportement
>
> Merci
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | CRUMEYROLLE Pierre | 2019-09-23 12:36:30 | Re: insert multi values limitations |
Previous Message | CRUMEYROLLE Pierre | 2019-09-23 09:25:31 | insert multi values limitations |