MySQL -- innodb中cardinality是如何統計的

來源:互聯網
上載者:User

標籤:format   status   預設   sql   form   count   子節點   存在   stat   

cardinality是放在mysql儲存引擎層進行的。採用的是採樣取值。
在innodb儲存引擎中,cardinality統計資訊的更新發生在兩個操作中:insert和update

更新策略為:
-表中1/16的資料發生過變化
-stat_modified_counter>2000 000 000(stat_modified_counter是innodb儲存引擎中的一個計數器)

預設Innodb儲存引擎對8個葉子節點進行採樣。受參數innodb_stats_sample_pages影響。

當執行語句analyze table、show table status、show index、訪問information_schema.tables、訪問information_schema.statistics時都會導致innodb儲存引擎重新計算cardinality的值(對應的參數請查閱文檔)。如果表中資料大,且存在多個輔助索引,以上操作可能會很慢。

MySQL -- innodb中cardinality是如何統計的

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.