[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

FullText & Join index

Asked by Stevod2 in MySQL Server

Tags: mysql fulltext index join

I have one table with a full text index, and another table to which I need to join, based on an ID field in the fulltext table. I can't get the join query to use non-fulltext table's index to do a ref join; it insists on doing an index scan on the second table. Is there any way to avoid the index scan?

The query is
SELECT
dm.MessageID, sm.DBID
FROM
tdistinctmessages dm,
tSite_messages sm
WHERE MATCH (dm.message) AGAINST ('"microsoft support"' IN BOOLEAN MODE)
AND dm.MessageID=sm.MessageID

Table definitions are:

CREATE TABLE `tdistinctmessages` (
  `message` VARCHAR(150) COLLATE latin1_general_ci NOT NULL,
  `MessageID` INT(10) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY  (`message`,`MessageID`),
  FULLTEXT KEY `FTIX_Message` (`message`)
) ENGINE=MYISAM AUTO_INCREMENT=26935581 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci


CREATE TABLE `tsite_messages` (
  `DBID` INT(10) NOT NULL,
  `wordID` BIGINT(20) UNSIGNED DEFAULT NULL,
  `MessageID` INT(10) DEFAULT NULL,
  `Repetition` INT(10) NOT NULL DEFAULT '0',
  `Emphasis` INT(10) NOT NULL DEFAULT '0',
  KEY `IX_DBID_WordID_MessageID_Repetition` (`DBID`,`wordID`,`MessageID`,`Repetition`),
  KEY `NewIndex1` (`MessageID`,`DBID`,`Repetition`)
) ENGINE=MYISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci

EXPLAIN IS

      possible_keys      key      key_len      ref      rows      Extra
1      SIMPLE      dm      fulltext      FTIX_Message      FTIX_Message      0            1      Using where
1      SIMPLE      sm      index      NewIndex1      NewIndex1      13      \N      27892950      Using where; Using index
[+][-]11/02/09 04:08 PM, ID: 25725086Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625