最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

MySQLInnoDB與PostgreSQL的PartialIndex(es)是不一樣

来源:动视网 责编:小采 时间:2020-11-09 13:04:54
文档

MySQLInnoDB與PostgreSQL的PartialIndex(es)是不一樣

MySQLInnoDB與PostgreSQL的PartialIndex(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 指的 Part
推荐度:
导读MySQLInnoDB與PostgreSQL的PartialIndex(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 指的 Part


而 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 可以設定「我只要索引一月一日出生的人的 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 的五個優點…
  • MySQL 對 VARCHAR 的 Index 空間佔用的問題…
  • Percona 的「Advanced MySQL Query Tuning」…
  • MySQL 5.7…
  • 用 Percona XtraBackup 備份時用 compact 模式節省空間…
  • 文档

    MySQLInnoDB與PostgreSQL的PartialIndex(es)是不一樣

    MySQLInnoDB與PostgreSQL的PartialIndex(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 指的 Part
    推荐度:
    标签: 不是 mysql index
    • 热门焦点

    最新推荐

    猜你喜欢

    热门推荐

    专题
    Top