How do I add indices to MySQL tables?

后端 未结 7 1915
北荒
北荒 2020-11-22 13:54

I\'ve got a very large MySQL table with about 150,000 rows of data. Currently, when I try and run

SELECT * FROM table WHERE id = \'1\';

the

7条回答
  •  时光取名叫无心
    2020-11-22 14:16

    You can use this syntax to add an index and control the kind of index (HASH or BTREE).

    create index your_index_name on your_table_name(your_column_name) using HASH;
    or
    create index your_index_name on your_table_name(your_column_name) using BTREE;
    

    You can learn about differences between BTREE and HASH indexes here: http://dev.mysql.com/doc/refman/5.5/en/index-btree-hash.html

提交回复
热议问题