Bug #77789 Too small chunks when sending huge parameters with COM_STMT_SEND_LONG_DATA
Submitted: 21 Jul 2015 6:19
Reporter: Andrii Nikitin Email Updates:
Status: Verified Impact on me:
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
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='',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
gradually increase chunk size if many iterations have passed