亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 2792 | 回復(fù): 0
打印 上一主題 下一主題

Mysql管理必備工具M(jìn)aatkit詳解之四(mk-duplicate-key-checker) [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2010-02-23 10:58 |只看該作者 |倒序?yàn)g覽

Mysql管理必備工具M(jìn)aatkit詳解之四(mk-duplicate-key-checker)
2009年05月19日 作者: 大頭剛 
mk-duplicate-key-checker - 檢查MYSQL重復(fù)索引,并給出刪除語(yǔ)句。安裝方法可以參考
這里
。
在oracle里,不允許在同一個(gè)列上創(chuàng)建多個(gè)索引,如果試圖創(chuàng)建就會(huì)報(bào)錯(cuò)如下:
CREATE INDEX sg1 ON uid_tmp(user_id);
CREATE INDEX sg1 ON uid_tmp(user_id)
                            *
ERROR AT line 1:
ORA-01408: such column list already indexed
而在mysql上,卻是允許的,不知道為何要這樣,總之是可以的。
mysql> create index sg1 on t1(id);
Query OK, 0 rows affected (0.07 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> create index sg2 on t1(id);
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> show index from t1;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| t1    |          0 | PRIMARY  |            1 | id          | A         |           2 |     NULL | NULL   |      | BTREE      |         |
| t1    |          1 | sg1      |            1 | id          | A         |           2 |     NULL | NULL   |      | BTREE      |         |
| t1    |          1 | sg2      |            1 | id          | A         |           2 |     NULL | NULL   |      | BTREE      |         |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
3 rows in set (0.00 sec)
在ID這個(gè)列上,居然有3個(gè)索引,顯然嚴(yán)重浪費(fèi)資源。如果你的數(shù)據(jù)庫(kù)有很多表,一個(gè)一個(gè)表去查看顯然是一件很費(fèi)力,很機(jī)械的事情,那么你可以用mk-duplicate-key-checker工具來(lái)幫你,使用很簡(jiǎn)單:
[root@mysql2 u01]# mk-duplicate-key-checker -u sg -p
# ########################################################################
# test.t1                                                                 
# ########################################################################

# sg1 is a duplicate of PRIMARY
# Column types:
#          `id` int(11) NOT NULL
# To remove this duplicate key, execute:
ALTER TABLE `test`.`t1` DROP KEY `sg1`;

# sg2 is a duplicate of PRIMARY
# Column types:
#          `id` int(11) NOT NULL
# To remove this duplicate key, execute:
ALTER TABLE `test`.`t1` DROP KEY `sg2`;

# ########################################################################
# Summary of keys                                                         
# ########################################################################

# Size Duplicate Keys   256
# Total Duplicate Keys  2
# Total Keys            293
給出了存在重復(fù)索引的表和列,以及刪除的語(yǔ)法。
OK,還有其他的一些參數(shù),可以看下幫助文件。
mk-duplicate-key-checker --help
mk-duplicate-key-checker examines MySQL tables for duplicate or redundant
indexes and foreign keys.  Connection options are read from MySQL option files.
For more details, please use the --help option, or try 'perldoc
/usr/bin/mk-duplicate-key-checker' for complete documentation.
Usage: /usr/bin/mk-duplicate-key-checker
Options:
  --all-structs       Compare indexes with different structs (BTREE, HASH, etc)
  --ask-pass          Prompt for a password when connecting to MySQL
  --charset       -A  Default character set
  --[no]clustered     PK columns appended to secondary key is duplicate (default
                      yes)
  --config            Read this comma-separated list of config files; if
                      specified, this must be the first option on the command
                      line
  --databases     -d  Check only this comma-separated list of databases
  --defaults-file -F  Only read mysql options from the given file
  --engines       -e  Do only tables whose storage engine is in this
                      comma-separated list
  --help              Show help and exit
  --host          -h  Connect to host
  --ignore-databases  Ignore this comma-separated list of databases
  --ignore-engines    Ignore this comma-separated list of storage engines
  --ignore-order      Ignore index order so KEY(a,b) duplicates KEY(b,a)
  --ignore-tables     Ignore this comma-separated list of tables
  --key-types         Check for duplicate f=foreign keys, k=keys or fk=both
                      (default fk)
  --password      -p  Password to use when connecting
  --port          -P  Port number to use for connection
  --set-vars          Set these MySQL variables (default wait_timeout=10000)
  --socket        -S  Socket file to use for connection
  --[no]sql           Print DROP KEY statement for each duplicate key (default
                      yes)
  --[no]summary       Print summary of indexes at end of output (default yes)
  --tables        -t  Check only this comma-separated list of tables
  --user          -u  User for login if not current user
  --verbose       -v  Output all keys and/or foreign keys found, not just
                      redundant ones
  --version           Show version and exit
Options and values after processing arguments:
  --all-structs       FALSE
  --ask-pass          FALSE
  --charset           (No value)
  --clustered         TRUE
  --config            /etc/maatkit/maatkit.conf,/etc/maatkit/mk-duplicate-key-checker.conf,
                         /root/.maatkit.conf,/root/.mk-duplicate-key-checker.conf
  --databases         (No value)
  --defaults-file     (No value)
  --engines           (No value)
  --help              TRUE
  --host              (No value)
  --ignore-databases
  --ignore-engines
  --ignore-order      FALSE
  --ignore-tables
  --key-types         fk
  --password          (No value)
  --port              (No value)
  --set-vars          wait_timeout=10000
  --socket            (No value)
  --sql               TRUE
  --summary           TRUE
  --tables            (No value)
  --user              (No value)
  --verbose           FALSE
  --version           FALSE


本文來(lái)自ChinaUnix博客,如果查看原文請(qǐng)點(diǎn):http://blog.chinaunix.net/u3/111930/showart_2184834.html
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP