Jump to content

MATCH AGAINST, why does it work without full text indexes?


Recommended Posts

I'm using a query like this:

SELECT firstname, lastname, mail, phone
FROM clients 
WHERE company_id='$company_id' AND
(MATCH(firstname,lastname,mail,phone,custom1,custom2,custom3) AGAINST ('$queryfixed' IN BOOLEAN MODE))
ORDER BY firstname, lastname, mail

 

$queryfixed is the query changed from "sam jones" to "+sam* +jones*"

 

Currently I have no full text index at all. All I have is normal indexes on mail, company_id and phone.

This is a table of around half a million rows, but each company_id has around 500-2000 clients, and most queries executes fast.

 

Is it correct that it works without any full text indexes at all?

 

I tried making a full text index with firstname, lastname, and there was no big time difference when I run it on a single company.

Users mostly search for first and last names, but sometimes also the custom fields.

 

Should I make an index convering all columns that are in the MATCH(...) clause, or only on the most frequently used, like first/last name?

I'm happy for any tips on how to optimize this, as the database grows!

 

I'm using version: 5.0.90

Ref: http://dev.mysql.com/doc/refman/5.5/en/fulltext-restrictions.html

 

The MATCH() column list must match exactly the column list in some FULLTEXT index definition for the table,

unless this MATCH() is IN BOOLEAN MODE. Boolean-mode searches can be done on nonindexed columns, although they are likely to be slow.

Interesting, thanks. So would it help if there is a fulltext index on (firstname,lastname) or does it still have to scan all rows? Seems logical that it would need to scan everything, since finding a match in any of those two wouldn't show all hits.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.