MySQL InnoDBとPostgreSQLのPartial Index(es)は違うもの…


MySQL InnoDBとは、Partial Indexのことです.
An index that represents only part of a column value, typically the first N characters (the prefix) of a long VARCHAR value.
PostgreSQLが指すPartial Indexesは次のとおりです.
A partial index is an index built over a subset of a table; the subset is defined by a conditional expression (called the predicate of the partial index). The index contains entries only for those table rows that satisfy the predicate. Partial indexes are a specialized feature, but there are several situations in which they are useful.
結論から言えば、PostgreSQLはMySQL InnoDBのPartial Indexがやりたいことをすることができ、さらに多くのことをすることができます.
MySQL InnoDBのPartial Indexはprefix index(文字列の前のn bytesに対して)に対して設定されており、可能な場合はCHAR(32)が前の16 bytesに対してのみインデックスされている.
PostgreSQLのPartial Indexesは多くの面でより強力な利益を得ています.Indexes on Expressionsがあるので、MySQLのprefixインデックスのようにsuffixをインデックスしたり、string functionを介してインデックスが得られた値をインデックスしたりすることができます.
PostgreSQLのように「私は1月1日に生まれた人のusernameをインデックスするだけです」を設定できます.CREATE INDEX test_index ON test_table (username) WHERE birth_month = 1 AND birth_day = 1;
MySQLではどうせ仕様化してindexを下ろしたり、別の表を取り外してindexを下ろしたりする必要がありますが、PostgreSQLの機能を上手に使えば手間が省けます...
Related Posts:
  • Instagram説明用PostgreSQLの5つの利点...
  • MySQL VARCHARのIndexスペース占有の問題...
  • Perconaの「Advanced MySQL Query Tuning」...
  • MySQL 5.7…
  • Percona XtraBackupバックアップ時にcompactモードで省スペース…