Efficient full-text searchs on large sets of data

Oct 15, 2010 11:48

A database application I've written uses a table with around 600,000 rows. Each row has a text field 500-5000 characters long. I periodically need to find all the rows containing a particular phone number, name, or address, ie.'123-4567', 'john smith', '1950 Main St N ( Read more... )

Leave a comment

Comments 3

el_diavalo October 16 2010, 14:15:52 UTC
I'm no MySQL optimization expert, but it almost sounds like you need a complete restructuring. Breaking out the phone, name, address, etc to their own fields, and searching for that specific one.

At that point, you can 'SELECT `date`, `name` FROM `tb_archive` WHERE `name` LIKE '%john smith%' ORDER BY `date` DESC"

Excluding the giant `text` field in the results would also speed up returns at that point.

It would take a lot of work, but it'd be worth it in the long run, IMHO.

Reply


awfief October 18 2010, 14:46:12 UTC
It's slow because there's no index that can be used. Fulltext indexing can be used to get exact matches only. You can change the default of 4 characters being the minimum size of a "word" if you want ( ... )

Reply


Stored procedure for Full Text shantanuo October 27 2010, 12:36:22 UTC

Leave a comment

Up