← Back to team overview

sslug-teknik team mailing list archive

MySQL fulltext search

 

Hey

Jeg har en tabel, hvor jeg har et fulltext index, men jeg kan ikke få
det til at performe særlig godt, og jeg forstår ikke hvorfor:

mysql> explain select count(*) from game_log_ng where match(log)
against("+nano" in boolean mode);
+----+-------------+-------------+----------+---------------+--------------+---------+------+------+-------------+
| id | select_type | table       | type     | possible_keys |
key          | key_len | ref  | rows | Extra       |
+----+-------------+-------------+----------+---------------+--------------+---------+------+------+-------------+
|  1 | SIMPLE      | game_log_ng | fulltext | fulltext_log  |
fulltext_log | 0       |      |    1 | Using where |
+----+-------------+-------------+----------+---------------+--------------+---------+------+------+-------------+
1 row in set (0,00 sec)

mysql> explain select count(*) from game_log_ng where log like "%nano%";
+----+-------------+-------------+------+---------------+------+---------+------+---------+-------------+
| id | select_type | table       | type | possible_keys | key  | key_len
| ref  | rows    | Extra       |
+----+-------------+-------------+------+---------------+------+---------+------+---------+-------------+
|  1 | SIMPLE      | game_log_ng | ALL  | NULL          | NULL | NULL   
| NULL | 5183656 | Using where |
+----+-------------+-------------+------+---------------+------+---------+------+---------+-------------+
1 row in set (0,00 sec)

mysql> select count(*) from game_log_ng where match(log) against("+nano"
in boolean mode);
+----------+
| count(*) |
+----------+
|  5127025 |
+----------+
1 row in set (33,93 sec)

mysql> select count(*) from game_log_ng where log like "%nano%";
+----------+
| count(*) |
+----------+
|  5127025 |
+----------+
1 row in set (2,93 sec)

mysql>


Hvordan kan det være, at den version, som bruger index tager mere end 10
gange så lang tid som den version, der IKKE bruger index ?
Jeg har også prøvet med andre ord så jeg kunne være sikker på, at MySQL
ikke brugte query cache eller omskrev mit query.

VH
Robert

Attachment: signature.asc
Description: OpenPGP digital signature


Follow ups