我有一个包含 6000 万多条记录的数据库。目前的设置是有 1 张桌子有 30+ 百万和几个小桌子,每张桌子有 500 万(ish)。每个表的数据结构都是相同的。第一次创建我们搜索的人(3-4 年前,在我来到这里之前)使用了多个小桌子。我们match against
为每个连接使用。我的老板和他的印象是,使用多个表可以让 MySQL 同时搜索每个表。在我读到的所有内容中,每个人都说一张大桌子会更好,但随着 30 多万张桌子变大,它的速度似乎会显着放缓,有时需要 40 多秒。这比它应该慢吗?
选择语句
SELECT $stuff FROM table1 WHERE MATCH (Name) AGAINST ('+john +smith' IN BOOLEAN MODE) UNION ALL
SELECT $stuff FROM table2 WHERE MATCH (Name) AGAINST ('+john +smith' IN BOOLEAN MODE) UNION ALL
SELECT $stuff FROM table3 WHERE MATCH (Name) AGAINST ('+john +smith' IN BOOLEAN MODE) UNION ALL
SELECT $stuff FROM table4 WHERE MATCH (Name) AGAINST ('+john +smith' IN BOOLEAN MODE) UNION ALL
SELECT $stuff FROM table5 WHERE MATCH (Name) AGAINST ('+john +smith' IN BOOLEAN MODE) UNION ALL
SELECT $stuff FROM table6 WHERE MATCH (Name) AGAINST ('+john +smith' IN BOOLEAN MODE) UNION ALL
SELECT $stuff FROM table7 WHERE MATCH (Name) AGAINST ('+john +smith' IN BOOLEAN MODE) UNION ALL
SELECT $stuff FROM table8 WHERE MATCH (Name) AGAINST ('+john +smith' IN BOOLEAN MODE) UNION ALL
SELECT $stuff FROM table9 WHERE MATCH (Name) AGAINST ('+john +smith' IN BOOLEAN MODE) UNION ALL
SELECT $stuff FROM table10 WHERE MATCH (Name) AGAINST ('+john +smith' IN BOOLEAN MODE)
这些表是 MyISAM,并且 col 上有一个全文索引Name
。Table3
是一个拥有 30+ 百万条记录(大约 10gb)的记录。将它放在一张表中或将其拆分会大大提高性能吗?我还缺少其他东西?或者是 60+ 百万条记录很大以获得对全文搜索的快速响应?