{"id":201,"date":"2022-06-05T08:46:52","date_gmt":"2022-06-04T23:46:52","guid":{"rendered":"https:\/\/www.b64.pw\/blog\/?p=201"},"modified":"2022-06-05T08:46:53","modified_gmt":"2022-06-04T23:46:53","slug":"mysql%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%a4%a7%e9%87%8f%e3%81%ab%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.b64.pw\/blog\/?p=201","title":{"rendered":"MySQL\u306e\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u5927\u91cf\u306b\u4f5c\u6210\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"\n<p>MySQL\u3067\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u624b\u8efd\u306b\u5927\u91cf\u306bINSERT\u3057\u305f\u3044\u3068\u304d\u306b\u4f7f\u3048\u308b\u65b9\u6cd5\u3002<br>\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3067WHILE\u3092\u4f7f\u3063\u3066\u7e70\u308a\u8fd4\u3057INSERT\u3059\u308b\u3053\u3068\u3067\u5b9f\u73fe\u3067\u304d\u308b\u304c\u3001<br>TiDB\u306a\u3069<a href=\"https:\/\/docs.pingcap.com\/tidb\/stable\/mysql-compatibility\">\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044<\/a>(2022\u5e746\u6708\u73fe\u5728)\u5834\u5408\u306e\u4ee3\u66ff\u624b\u6bb5\u3068\u3057\u3066<br><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/insert-select.html\">INSERT ~ SELECT<\/a>\u6587\u3067\u30ec\u30b3\u30fc\u30c9\u3092\u6bd4\u8f03\u7684\u9ad8\u901f\u306bINSERT\u3067\u304d\u308b\u3002(\u3082\u3061\u308d\u3093MySQL\u3067\u3082\u3067\u304d\u308b)<\/p>\n\n\n\n<p>\u4f8b\u3048\u3070\u3053\u3093\u306a\u30c6\u30fc\u30d6\u30eb\u304c\u3042\u308b\u3068\u3057\u3066<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE TABLE `idxtest` (\n  `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n  `txt` char(255) DEFAULT NULL,\n  INDEX(`data`)\n)<\/code><\/pre>\n\n\n\n<p>\u307e\u305a1\u30ec\u30b3\u30fc\u30c9\u4f5c\u308b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT INTO idxtest SET txt=SHA2(0,512); <\/code><\/pre>\n\n\n\n<p>\u305d\u306e\u5f8cINSERT ~ SELECT\u6587\u3067\u81ea\u5df1\u53c2\u7167\u3057\u3066\u30ec\u30b3\u30fc\u30c9\u3092\u500d\u3005\u306b\u5897\u3084\u3057\u3066\u3044\u304f<br>(SELECT\u3055\u308c\u308b\u30c6\u30fc\u30d6\u30eb\u3068INSERT\u3055\u308c\u308b\u30c6\u30fc\u30d6\u30eb\u304c\u540c\u3058\u3068\u3044\u3046\u306e\u304c\u30dd\u30a4\u30f3\u30c8)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT idxtest (txt) SELECT UUID() as txt FROM idxtest; # 2\u30ec\u30b3\u30fc\u30c9\u306b\u306a\u308b\nINSERT idxtest (txt) SELECT UUID() as txt FROM idxtest; # 4\u30ec\u30b3\u30fc\u30c9\u306b\u306a\u308b\nINSERT idxtest (txt) SELECT UUID() as txt FROM idxtest; # 8\u30ec\u30b3\u30fc\u30c9\u306b\u306a\u308b\n...\nINSERT idxtest (txt) SELECT UUID() as txt FROM idxtest; # 20\u56de\u7e70\u308a\u8fd4\u3059\u30682^20 \u2252 100\u4e07\u30ec\u30b3\u30fc\u30c9\u307b\u3069\u306b\u306a\u308b<\/code><\/pre>\n\n\n\n<p>\u306a\u304aTiDB\u3067\u3082\u3042\u308b\u7a0b\u5ea6\u540c\u69d8\u306b\u5b9f\u884c\u3067\u304d\u308b\u304c\u5927\u91cf\u306b\u4f5c\u6210\u3057\u3066\u3044\u308b\u3068\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SQL Error &#91;8004] &#91;HY000]: Transaction is too large, size: 104857633<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/docs.pingcap.com\/tidb\/v2.1\/tidb-faq#the-error-message-transaction-too-large-is-displayed\">\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u306b\u3088\u308b\u3068\u3069\u3046\u3084\u30892Phase Commit\u3092\u5185\u90e8\u3067\u884c\u3063\u3066\u3044\u308b\u95a2\u4fc2\u3067\u4e0b\u8a18\u5236\u9650\u306b\u5f15\u3063\u304b\u304b\u3063\u3066\u3044\u308b\u6a21\u69d8\u3002<br>(\u4eca\u56de\u306e\u30b1\u30fc\u30b9\u3067\u306ftotal size\u306e100MB\u306b\u5f15\u3063\u304b\u304b\u3063\u305f)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>A transaction is limited to 5000 SQL statements (by default)\nEach Key-Value entry is no more than 6MB\nThe total number of Key-Value entry is no more than 300,000 rows\nThe total size of Key-Value entry is no more than 100MB<\/code><\/pre>\n\n\n\n<p>\u56de\u907f\u7b56\u3068\u3057\u3066\u306f\u6b21\u306e\u3088\u3046\u306bLIMIT\u3092\u3064\u3051\u308b\u3068\u3044\u3046\u624b\u304c\u8003\u3048\u3089\u308c\u308b\u304c\u3001\u3053\u306e\u65b9\u6cd5\u306e\u3046\u307e\u307f\u304c\u6e1b\u308b\u306e\u3067\u5c11\u3005\u5fae\u5999\u304b\u3082\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT idxtest (txt) SELECT UUID() as txt FROM idxtest LIMIT 500000;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>MySQL\u3067\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u624b\u8efd\u306b\u5927\u91cf\u306bINSERT\u3057\u305f\u3044\u3068\u304d &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9,17,18],"tags":[],"_links":{"self":[{"href":"https:\/\/www.b64.pw\/blog\/index.php?rest_route=\/wp\/v2\/posts\/201"}],"collection":[{"href":"https:\/\/www.b64.pw\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.b64.pw\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.b64.pw\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.b64.pw\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=201"}],"version-history":[{"count":9,"href":"https:\/\/www.b64.pw\/blog\/index.php?rest_route=\/wp\/v2\/posts\/201\/revisions"}],"predecessor-version":[{"id":222,"href":"https:\/\/www.b64.pw\/blog\/index.php?rest_route=\/wp\/v2\/posts\/201\/revisions\/222"}],"wp:attachment":[{"href":"https:\/\/www.b64.pw\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.b64.pw\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.b64.pw\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}