天天看點

MYSQL BLOB 字段大小以及個數的限制測試。

測試結論

mysql版本号 5.1

    表類型: innodb, row_format=compact (這是預設的行格式)

    插入超過10個blob, blob的資料量非常小(<768位元組), 插入成功。

    插入超過10個blob, blob的資料量非常大(>768位元組), 插入失敗:報 Got error 139 from storage engine。

    注意,假設mysqlserver版本号是5.1, innodb_file_format選項不存在, 也就無從談起Barracuda格式。 設定row_format=dynamic也是沒意義的。

mysql版本号 5.5

    表類型: innodb, row_format=compact (這是預設的行格式)

    插入超過10個blob, blob的資料量非常大(>768位元組), 插入失敗:報 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.

    表類型: innodb, row_format=dynamic (這是innodb的新檔案存儲格式Barracuda所支援的行格式)

    插入超過10個blob, blob的資料量非常大(>768位元組), 插入成功

備注:

    1) 實際測試測試我用的每一個字段長度都是100K+

    2) 對于mysql5.5, 盡管支援Barracuda。可是預設使用的還是老的格式:Antelope

        除非在mysql的配置裡面my.cnf改動:

        innodb_file_per_table = 1                                                                                                                                  

        innodb_file_format = Barracuda

        或者set global 指令動态的改動:

        SET GLOBAL innodb_file_format=barracuda;

        SET GLOBAL innodb_file_per_table=1;

        注意:

        1) 改動後的innodb_file_format格式, 僅僅影響興許建立的表。 也就是興許建立的表,能夠支援把row_format設為dynamic

        2) SET GLOBAL 僅僅是在mysqlserver執行期間有效,重新啟動後innodb_file_format還原為原來的格式。

    3) 推斷一個表是否支援超過10個blob的字段的簡單辦法:

        show table status like 't1' \G

        檢視 Row_format , 假設是Compact, 必然不支援, 假設是dynamic, 則支援。