Bug #4464 full text index search speed differs between count queries of the same type
Submitted: 8 Jul 2004 15:11 Modified: 9 Mar 2005 13:15
Reporter: Karsten Wenger Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: FULLTEXT search Severity:S4 (Feature request)
Version:4.1.1-alpha-max-log OS:Linux (linux)
Assigned to: Assigned Account CPU Architecture:Any

[8 Jul 2004 15:11] Karsten Wenger
Description:
The following 2 queries on the full text index seem to depend on the cardinality of the search item. Since the cardinality should be known and remembered after indexing, the simple count statements should take the same amount of time.

mysql> select  count(*) from sentences WHERE MATCH (sentence) AGAINST ('apop');
+----------+
| count(*) |
+----------+
|       21 |
+----------+
1 row in set (0.06 sec)

mysql> select  count(*) from sentences WHERE MATCH (sentence) AGAINST ('endometriosis');
+----------+
| count(*) |
+----------+
|    14711 |
+----------+
1 row in set (35.10 sec)

How to repeat:
Make a DB with full text index and look for token of different frequency like the two above.

Suggested fix:
Determine and use the cardinality of each token known after indexing.