Im making a (small) site in php & mysql. The mysql database consists of a single table with possibly tens of thousands of rows (in the future).
I only need to get results from one column which has a character limit of 200.
Considering that I don’t want any stopwords or “common” word features; and the column contains filenames (some with special characters), what type of search would you recommend?
EDIT: Just some more clarification on filenames:
I don’t want to do an exact match; say I have a name like this: [abc]_random_file.txt; searching for “abc random” OR “[abc] random” OR “abc txt” should all match. Hope that makes sense.
I’ve considered:
1—-SQL like statement
2—-SQL regexps (as shown on this website: http://www.iamcal.com/publish/articles/php/search/ )
3—-Mysql Full-Text Search(MyISAM)
4—-Third party search engines(really don’t want to do this)
With #2 I can probably get the results I want, however I don’t think it would work well with my table if it gets big?
Would appreciate any help; im a real beginner to all this and I’ve been googling all day 🙁
What do you need to search? Optimizations can often be found when you take in account the limitations of your searches. For instance, if you only need to find all the rows that start with a specific text, you can add a simple index and use
LIKE, which will give instant results.In general, if a simple equality or LIKE will do, those will probably perform best. A regexp will anyway do a full scan. However even if there were a 100,000 rows, it would still take up mere 20MB in RAM, so a full scan through all that will not be very slow (unless you’re on an ancient server).
I’d say – try the simple approach first and see what happens. If the performance reaches unacceptable levels, you should be easily able to change your approach. After all – you did state that the website was small.
Added: Just read your update. Sounds like a job for MySQL’s fulltext index. Try it to see if it works for you.