LoginSignup
0
0

More than 3 years have passed since last update.

MySQLで使用パーティションの実行計画をとるメモ

Posted at

sqlのチューニングで実行計画をとりたいときは
EXPLAINをよく使うと思いますが、テーブルの使用パーティションを確認する際は

EXPLAIN PARTITIONS {クエリ}

で使用しているpartitions情報を取得できます。

explain select * from user_hoge_log where start >= UNIX_TIMESTAMP('2019-09-01');

id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE user_hoge_log p0,p1,p2,p3 ALL NULL NULL NULL NULL 2611 33.33 Using

※パーティション化されていないテーブルでEXPLAIN PARTITIONSを使用すると、
エラーは発生しませんが、partitionsカラムの値は常に NULL となります。

ちなみに試してみたところ、

MySQL5.6ではpartitions指定は明示的に必要でしたが、
MySQL5.7ではpartitions指定はなしでもpartitions項目は表示されたのでデフォルトでオンのようです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0