官术网_书友最值得收藏!

Using extended keys with InnoDB and XtraDB

When creating an execution plan for a query, the MariaDB optimizer makes a cost-based decision about whether or not to use one or more indexes instead of reading through a table row-by-row. Indexes are often, but not always the faster choice. The extended key's optimization improves the index lookups for InnoDB and XtraDB tables.

How to do it...

  1. Launch the mysql command-line client application and connect it to our MariaDB server as the root user or as a user with the SUPER privilege.
  2. Enable the extended keys optimization with the following command:
    SET GLOBAL optimizer_switch='extended_keys=on';
    
  3. Add the following code to our my.cnf or my.ini file (or to an existing [mysqld] section):
    [mysqld]
  4. optimizer_switch = 'extended_keys=on' verifies that extended_keys is set to on with the following command:
    SHOW VARIABLES LIKE 'optimizer_switch'\G
    

How it works...

In this recipe, we turn on the extended_keys optimization globally for the running server and we then make the change permanent by adding it to our my.cnf config file. In this way, we turn the feature on, and then ensure that it stays on, without having to restart MariaDB.

There's more...

Many InnoDB or XtraDB tables have more than one key, for example, a primary key on the id column and a secondary key on the username column. Using the extended_keys optimization, MariaDB is able to create execution plans for some queries, which only touch the indexes of those keys. It does this by looking at the keys, and if all of the information that we are looking for is present, MariaDB uses that information instead of looking through tables row by row.

See also

主站蜘蛛池模板: 项城市| 河曲县| 伊川县| 崇左市| 樟树市| 莱州市| 襄垣县| 永仁县| 镇江市| 六盘水市| 惠安县| 库车县| 南充市| 乌拉特中旗| 柳林县| 铁力市| 泰和县| 大邑县| 石林| 厦门市| 广昌县| 牟定县| 垫江县| 普安县| 八宿县| 宜昌市| 宣武区| 庆安县| 乐陵市| 淮南市| 九江县| 通州市| 保德县| 稻城县| 定安县| 阳东县| 义乌市| 宝应县| 民勤县| 云安县| 乌兰浩特市|