MySQL Forums
Forum List  »  Full-Text Search

Re: Full-text search slower than like
Posted by: Philipp Prelicz
Date: February 10, 2010 12:01PM

CREATE TABLE `pilz_pilz` (
`PilzID` int(11) NOT NULL,
`Pilz` text NOT NULL,
PRIMARY KEY (`PilzID`),
FULLTEXT KEY `Pilz` (`Pilz`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1

---

Explain SELECT *
FROM pilz_pilz
WHERE MATCH pilz AGAINST ('xyz*' IN boolean MODE)

id...select_type...table...type...possible_keys...key...key_len...ref...rows...Extra
1....SIMPLE.....pilz_pilz.fulltext....Pilz........Pilz...0................1...Using where

---

SHOW TABLE STATUS LIKE 'pilz_pilz'

Name.......Engine....Version.....Row_format...Rows...Avg_row_length......Data_length......Max_data_length
pilz_pilz..MyISAM......10..........Dynamic...134018....36......4947240..281474976710655....6019072

Index_length...Data_free...Auto_increment....Create_time...........Update_time.........Check_time.........Collation.......Checksum
0................NULL..................2009-12-05.20:13:23...2009-12-05.20:13:25..2009-12-05.20:13:39....latin1_swedish_ci..NULL

---

Following statement with "match against" needs 1 to 1.5 seconds

SELECT *
FROM pilz_pilz
WHERE MATCH pilz AGAINST ('bole*' IN boolean MODE)
LIMIT 0 , 30

whereas the like version only needs around 0.003 seconds

SELECT *
FROM pilz_pilz
WHERE pilz LIKE '%bole%'
LIMIT 0 , 30

---

The table contains 134,018 rows.
The column pilz has around 2 - 4 words (many of the words are unique or only occure in a few rows)

I already tested this on two different servers - same results. (1. my home server with windows; 2. shared hosting on linux)

---

best regards
Philipp

Options: ReplyQuote


Subject
Views
Written By
Posted
7117
December 11, 2009 12:42PM
2862
February 07, 2010 02:04PM
2693
February 07, 2010 06:14PM
Re: Full-text search slower than like
2839
February 10, 2010 12:01PM
2824
February 10, 2010 08:26PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.