Bug #38842 | Fix for 25951 seems incorrect | ||
---|---|---|---|
Submitted: | 18 Aug 2008 8:17 | Modified: | 12 Dec 2008 1:39 |
Reporter: | Pavamanaprasad Athani | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.0.45, 4.1, 5.0, 5.1, 6.0 bzr | OS: | Any |
Assigned to: | Sergey Vojtovich | CPU Architecture: | Any |
Tags: | boolean, force index, full text, ignore index, index hints, regression |
[18 Aug 2008 8:17]
Pavamanaprasad Athani
[18 Aug 2008 8:39]
Sveta Smirnova
Thank you for the report. Please provide output of SHOW CREATE TABLE feature_name
[18 Aug 2008 9:10]
Pavamanaprasad Athani
CREATE TABLE `feature_name` ( `id` int(10) unsigned NOT NULL auto_increment, `geofeature_id` int(10) unsigned NOT NULL, `info` text character set latin1, PRIMARY KEY USING BTREE (`id`), KEY `gf` (`geofeature_id`), FULLTEXT KEY `ftinfo` (`info`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
[18 Aug 2008 13:14]
Sveta Smirnova
Thank you for the feedback. Please provide output of SHOW CREATE TABLE geofeature also.
[18 Aug 2008 13:28]
Pavamanaprasad Athani
Sorry. Forgot that. Here it is: CREATE TABLE `geofeature` ( `id` int(10) unsigned NOT NULL auto_increment, `object_id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `obj` (`object_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
[18 Aug 2008 14:02]
Sveta Smirnova
Thank you for the feedback. I can not repeat described behavior with test data. Please try current version 5.0.67 and if problem still exists provide output of EXPLAIN and, if possible, dump of these 2 tables.
[19 Aug 2008 7:03]
Pavamanaprasad Athani
Restore this file to create data for reproducing the bug
Attachment: indextest 20080819 1229.sql (text/plain), 43.06 KiB.
[19 Aug 2008 7:09]
Pavamanaprasad Athani
I have attached the sql file which you can restore to create the data required for reproducing the buggy behaviour. After recreating the data, use this query to reproduce the issue: explain select * from feature_name fn force index(gf) ,geofeature g where match (fn.info) against ('+4' in boolean mode) and fn.geofeature_id = g.id and g.object_id = 1; You will see that for table 'fn', key 'ftinfo' is being used in spite of using 'force index(gf)' for it.
[19 Aug 2008 7:12]
Pavamanaprasad Athani
Here is the output of EXPLAIN: id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE g const PRIMARY,obj obj 4 const 1 (null) 1 SIMPLE fn fulltext gf,ftinfo ftinfo 0 (null) 1 Using where
[19 Aug 2008 9:01]
Sveta Smirnova
Thank you for the data provided. Verified as described.
[7 Nov 2008 19:37]
Sergey Vojtovich
Risk and effort to fix are set with assumption that we will re-enable index hints for boolean mode searches. If this is not the case it may be not that trivial to fix.
[10 Nov 2008 11:27]
Sergey Vojtovich
Fulltext indexes are very different from regular indexes. The decision whether to use fulltext index is done earlier than the decision for regular indexes. That means to make true support for index hints for fulltext indexes would require a huge rewrite of fulltext engine at SQL layer. Anyway I'd agree that for boolean mode searches ignore fulltext index and force regular index are useful hints. What we could do is to implement special handling of index hints for fulltext indexes with the following characteristic: - all index hints will still be ignored for NLQ mode searches - it cannot work without index; - index hints FOR ORDER BY and FOR GROUP BY will still be ignored for fulltext indexes; - USE/FORCE index hints will still be ignored for fulltext indexes; - BOOLEAN mode searches will honor IGNORE INDEX hint; - BOOLEAN mode searches will honor FORCE/USE INDEX hints for regular indexes. This sounds like a good compromise and should solve all the problems mentioned in this bug report.
[10 Nov 2008 12:46]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/58332 2705 Sergey Vojtovich 2008-11-10 BUG#38842 - Fix for 25951 seems incorrect Prior to fix for bug 25951 index hints were honored for fulltext indexes, though most of them were not working as expected. With fix for bug 25951 index hints have no effect for fulltext indexes, which is correct, but doesn't allow users to provide some really useful hints to optimizer. Though it is not that trivial to make true index hints support for fulltext indexes, this patch implements special index hints support for fulltext indexes with the following characteristics: - all index hints are still ignored for NLQ mode searches - it cannot work without index; - index hints FOR ORDER BY and FOR GROUP BY are still ignored for fulltext indexes; - USE/FORCE index hints are still ignored for fulltext indexes; - BOOLEAN mode searches honor IGNORE INDEX hint; - BOOLEAN mode searches honor FORCE/USE INDEX hints for regular indexes.
[11 Nov 2008 10:13]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/58434 2712 Sergey Vojtovich 2008-11-11 BUG#38842 - Fix for 25951 seems incorrect With fix for bug 25951 index hints are ignored for fulltext searches, as handling of fulltext indexes is different from handling regular indexes. Meaning it is not possible to implement true index hints support for fulltext indexes within the scope of current fulltext architecture. The problem is that prior to fix for bug 25951, some useful index hints still could be given for boolean mode searches. This patch implements special index hints support for fulltext indexes with the following characteristics: - all index hints are still ignored for NLQ mode searches - it cannot work without an index; - for 5.1 and up index hints FOR ORDER BY and FOR GROUP BY are still ignored for fulltext indexes; - boolean mode searches honor USE/FORCE/IGNORE INDEX hints; - as opposed to index hints for regular indexes, index hints for fulltext BOOLEAN mode searches affect the usage of the index for the whole query.
[30 Nov 2008 17:01]
Sergey Petrunya
The page http://dev.mysql.com/doc/refman/5.1/en/index-hints.html says "Index hints do not work for FULLTEXT indexes". Please make sure to update that manual chapter when this fix is pushed.
[2 Dec 2008 13:02]
Bugs System
Pushed into 5.0.74 (revid:svoj@mysql.com-20081111091051-54pr96nf1z2s30gx) (version source revid:svoj@mysql.com-20081118111052-mo4zszzz1itieaan) (pib:5)
[8 Dec 2008 10:22]
Bugs System
Pushed into 5.1.31 (revid:svoj@mysql.com-20081111091051-54pr96nf1z2s30gx) (version source revid:patrick.crews@sun.com-20081126180318-v685u61mpgoc176x) (pib:5)
[8 Dec 2008 11:33]
Bugs System
Pushed into 6.0.9-alpha (revid:svoj@mysql.com-20081111091051-54pr96nf1z2s30gx) (version source revid:ingo.struewing@sun.com-20081121151447-dtf2ofz2ys0zqed1) (pib:5)
[12 Dec 2008 1:39]
Paul DuBois
Noted in 5.0.74, 5.1.31, 6.0.9 changelogs, and index-hints section. For 5.0: For natural language mode searches, index hints are silently ignored. For example, IGNORE INDEX(i) is ignored with no warning and the index is still used. For boolean mode searches, index hints are honored. For 5.1+: For natural language mode searches, index hints are silently ignored. For example, IGNORE INDEX(i) is ignored with no warning and the index is still used. For boolean mode searches, index hints with FOR ORDER BY or FOR GROUP BY are silently ignored. Index hints with FOR JOIN or no FOR modifier are honored. In contrast to how hints apply for non-FULLTEXT searches, the hint is used for all phases of query execution (finding rows and retrieval, grouping, and ordering). <i>This is true even if the hint is given for a non-FULLTEXT index.</i> For example, the following two queries are equivalent: SELECT * FROM t USE INDEX (index1) IGNORE INDEX (index1) FOR ORDER BY IGNORE INDEX (index1) FOR GROUP BY WHERE ... IN BOOLEAN MODE ... ; SELECT * FROM t USE INDEX (index1) WHERE ... IN BOOLEAN MODE ... ;
[19 Jan 2009 11:21]
Bugs System
Pushed into 5.1.31-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090119095303-uwwvxiibtr38djii) (version source revid:tomas.ulin@sun.com-20090108105244-8opp3i85jw0uj5ib) (merge vers: 5.1.31-ndb-6.2.17) (pib:6)
[19 Jan 2009 12:59]
Bugs System
Pushed into 5.1.31-ndb-6.3.21 (revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (version source revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (merge vers: 5.1.31-ndb-6.3.21) (pib:6)
[19 Jan 2009 16:05]
Bugs System
Pushed into 5.1.31-ndb-6.4.1 (revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (version source revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (merge vers: 5.1.31-ndb-6.4.1) (pib:6)
[5 Feb 2009 19:52]
Paul DuBois
Noted in 5.0.72sp1 changelog.