English 中文(简体)
Max JSON栏长
原标题:Max JSON column length in MySQL
  • 时间:2016-11-21 00:28:25
  •  标签:
  • mysql
  • json

我能把我最多的东西储存在我的SQL的一栏中? 我看不到《我的后勤手册》中提到的情况。

最佳回答

这里谈论的是@JorgeLondoño。

2. 设定服务器的最大允许包装尺寸:

mysql> set global max_allowed_packet=1024*1024*1024;

• 取消并再次开放我的客户,从而确定客户的最大包装规模,以便:

$ mysql --max-allowed-packet=$((1024*1024*1024))

a. 设立一个有色人听记的测试表,填写时间最长的线人文件如下:

mysql> create table test.jtest ( j json );

mysql> insert into test.jtest 
  set j = concat( [ , repeat( "word", , 100000000),  "word"] );
Query OK, 1 row affected (1 min 49.67 sec)

mysql> select length(j) from test.jtest;
+-----------+
| length(j) |
+-----------+
| 800000008 |
+-----------+

This shows that I was able to create a single JSON document with 100 million elements, and MySQL stores this in approximately 800MB.

我没有尝试一份较长的文件。 我假定在1 GB中达到最高点,这是你可以确定的最大值。

问题回答

JSON栏中储存的JSON文件数量限于<代码>的数值。 (尽管服务器在内部对一名初等人物的记忆进行操纵,但这种数值可能更大;该限额在服务器储存时适用。)

Command-Line Format --max_allowed_packet=#
System Variable Name    max_allowed_packet
Variable Scope  Global, Session
Dynamic Variable    Yes
Permitted Values    Type    integer
Default 4194304
Min Value   1024
Max Value   1073741824

Max allowed size for json data type field in MySql is 1GB. If json is less than 8k in size then it will be store as part of the row itself, just like other data types. On other hand json larger than 8k will be moved to seperate space as a document and individual SQL row will have pointer to that document.

我建议处理错误,如果你认为上载的json可能比1GB OR要好得多,如果你在将json储存到银行之前能够检查其大小。

信息源链接here





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签