Bug #77789 Too small chunks when sending huge parameters with COM_STMT_SEND_LONG_DATA
Submitted: 21 Jul 2015 6:19 Modified: 8 Feb 2023 17:04
Reporter: Andrii Nikitin Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:2.0.4 OS:Any
Assigned to: CPU Architecture:Any

[21 Jul 2015 6:19] Andrii Nikitin
Description:
Sending 1G parameter with COM_STMT_SEND_LONG_DATA takes hours in connector/Py.
In contrast, C program does the same almost instantly.

connection.py uses 8K chunks, which will result in hundreds of thousand calls for huge parameters:

    def cmd_stmt_send_long_data(self, statement_id, param_id, data):
        chunk_size = 8192

How to repeat:
import mysql.connector
import io

cnx = mysql.connector.connect(host='127.0.0.1',port=5623,user='root',password='',database='test')

cur = cnx.cursor(prepared=True)
cur.execute("SELECT %s", (io.BytesIO(bytes("A"*1000*1024*1024, "latin1")), ))

Suggested fix:
Set chunk size as property of connection
or
gradually increase chunk size if many iterations have passed
[8 Feb 2023 17:04] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/Python 8.0.33 release, and here's the proposed changelog entry from the documentation team:

Increased data chunk size from 8 KB to 128 KB to increase performance for
larger inputs.

Thank you for the bug report.