0

次のように、テーブル (innodb または ndb) から 300,000 行を ndb テーブルに移動するとします。

INSERT INTO ndbtable2
SELECT a, b,IFNULL(c,UTC_TIMESTAMP()),CASE WHEN b = 'X' THEN e ELSE d END,f
FROM ndbtable1;

Query OK, 308372 rows affected (5 min 12.59 sec)
Records: 308372  Duplicates: 0  Warnings: 0

ndb は、完了するまで、ますます膨大な量のデータ メモリを使用します。ビフォー/ピーク/アフターは以下の通り

ndb_mgm -e "all report memoryusage"
Connected to Management Server at: fl-prd-mysql1:1186
Node 1: Data usage is 2%(5752 32K pages of total 262144)
Node 1: Index usage is 0%(2428 8K pages of total 262176)
Node 2: Data usage is 2%(5752 32K pages of total 262144)
Node 2: Index usage is 0%(2428 8K pages of total 262176)

Connected to Management Server at: fl-prd-mysql1:1186
Node 1: Data usage is 62%(164013 32K pages of total 262144)
Node 1: Index usage is 1%(3136 8K pages of total 262176)
Node 2: Data usage is 62%(164013 32K pages of total 262144)
Node 2: Index usage is 1%(3136 8K pages of total 262176)

Connected to Management Server at: fl-prd-mysql1:1186
Node 1: Data usage is 3%(10293 32K pages of total 262144)
Node 1: Index usage is 1%(4590 8K pages of total 262176)
Node 2: Data usage is 3%(10293 32K pages of total 262144)
Node 2: Index usage is 1%(4590 8K pages of total 262176)

私の計算が正しければ、10293 - 5752 = 4541 = 142 MBを挿入しますが、メモリは 164013 - 5752 = 158261 = 4945 MB急増します

また、挿入を 50,000 行に制限し、前後の差が 3MB だけの場合、スパイクは 780MB でした。

明らかに、これは ndb が空でない場合に問題になります...ここで何が起こっているのですか?!

4

1 に答える 1

0

説明がない場合、マニュアルは次のように制限を認めています

この章の他の箇所で説明したように、MySQL Cluster は大規模なトランザクションを適切に処理しません。非常に多くの操作を含む 1 つの大きなトランザクションを試みるよりも、それぞれ少数の操作で多数の小さなトランザクションを実行する方が適切です。他の考慮事項の中で、大規模なトランザクションには非常に大量のメモリが必要です

http://dev.mysql.com/doc/refman/5.5/en/mysql-cluster-limitations-transactions.html

「この章の他の場所で述べたように」 ... 調べましたが、具体的なものはまだ見つかりません。

参考までに、代替案は次のとおりです。

  1. 行で反復をループしますLIMIT(たとえば、10,000)
  2. 空のテーブルに挿入する場合は、LOAD DATAinnodb と finally を検討するか、使用することさえALTER TABLE ... ENGINE = ndbclusterできます (どちらもトランザクションではありません) 。
于 2013-11-12T21:22:55.763 に答える