SELECT COUNT(*) FROM backlinkurl LEFT JOIN urlinformation ON (backlinkurl.urlrank=urlinformation.urlid AND backlinkurl.keywordid=urlinformation.keywordid)
里面的表backlinkurl 和 urlinformation 的都是超过 50000条的,联合起来查询,很慢,要怎么优化才比较快?
里面的表backlinkurl 和 urlinformation 的都是超过 50000条的,联合起来查询,很慢,要怎么优化才比较快?
show index from urlinformation;贴出来看一下。
index of urlinformation is also id( primary)
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| table1 | 0 | PRIMARY | 1 | id | A | 3 | NULL | NULL | | BTREE | |
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
1 row in set (0.14 sec)mysql>
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| table1 | 0 | PRIMARY | 1 | id | A | 3 | NULL | NULL | | BTREE | |
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
1 row in set (0.14 sec)
这个是从DOS里面黏贴过来的还是哪个工具上来的?
一般我们的索引键在联接字段 分组字段 排序字段和 where条件筛选字段