apache / shardingsphere

Distributed SQL transaction & query engine for data sharding, scaling, encryption, and more - on any database.
Apache License 2.0
19.65k stars 6.67k forks source link

Ask about batch update support #31012

Closed corgy-w closed 2 months ago

corgy-w commented 2 months ago

Does sharding support updatebatch now

ex:

 <update id="batchUpdateByPrimaryKeySelective" parameterType="java.util.List">
        <foreach collection="list" item="item" separator=";">
            UPDATE users SET
            tenant_id = #{item.tenantId},
            phone = #{item.phone},
            phone_cipher = #{item.phoneCipher},
            email = #{item.email},
            email_cipher = #{item.emailCipher},
            ssn = #{item.ssn},
            ssn_cipher = #{item.ssnCipher},
            is_deleted = 'N',
            creator = 'seatunnel',
            modifier = 'seatunnel',
            gmt_created = #{item.gmtCreated},
            gmt_modified = #{item.gmtModified}
            WHERE tenant_id = #{item.tenantId} AND id = #{item.id}
        </foreach>
    </update>
zzyReal666 commented 2 months ago
corgy-w commented 2 months ago
  • I have tested SQLServe using JDBC and it supports batch processing.
  • AS for your ORM framework,you can do a simple test.
UPDATE users SET
            tenant_id = ?,
            phone = ?,
            phone_cipher = ?,
            email = ?,
            email_cipher = ?,
            ssn = ?,
            ssn_cipher = ?,
            is_deleted = 'N',
            creator = 'seatunnel',
            modifier = 'seatunnel',
            gmt_created = ?,
            gmt_modified = ?
            WHERE tenant_id = ? AND id = ?; 
            UPDATE users SET
            tenant_id = ?,
            phone = ?,
            phone_cipher = ?,
            email = ?,
            email_cipher = ?,
            ssn = ?,
            ssn_cipher = ?,
            is_deleted = 'N',
            creator = 'seatunnel',
            modifier = 'seatunnel',
            gmt_created = ?,
            gmt_modified = ?
            WHERE tenant_id = ? AND id = ? 

I have tested update batch and it not support . shariding version :5.2.1. Example statement above

Error as follows image

zzyReal666 commented 2 months ago
  • I have tested SQLServe using JDBC and it supports batch processing.
  • AS for your ORM framework,you can do a simple test.
UPDATE users SET
            tenant_id = ?,
            phone = ?,
            phone_cipher = ?,
            email = ?,
            email_cipher = ?,
            ssn = ?,
            ssn_cipher = ?,
            is_deleted = 'N',
            creator = 'seatunnel',
            modifier = 'seatunnel',
            gmt_created = ?,
            gmt_modified = ?
            WHERE tenant_id = ? AND id = ?; 
            UPDATE users SET
            tenant_id = ?,
            phone = ?,
            phone_cipher = ?,
            email = ?,
            email_cipher = ?,
            ssn = ?,
            ssn_cipher = ?,
            is_deleted = 'N',
            creator = 'seatunnel',
            modifier = 'seatunnel',
            gmt_created = ?,
            gmt_modified = ?
            WHERE tenant_id = ? AND id = ? 

I have tested update batch and it not support . shariding version :5.2.1. Example statement above

Error as follows image

zzyReal666 commented 2 months ago