mysql - Which SQL query is better, MATCH AGAINST or LIKE? -
To find the database of those rows in which "foo" and "bar" both in one of the "foo_desc" columns The keywords "Bar_desc" will do something like:
SELECT * T1 from WHERE MATCH (t1.foo_desc, t2.bar_desc) ('+ foo * + bar *' in bullion mode) < '% Foo%' like / code> or
SELECT * to T1 WHERE (CONCAT (t1.foo_desc, t2.bar_desc) and (CONCAT (t1 . Foo_desc, t2.bar_desc) '<% bar%')
I hope the negative side of the last query is displayed.
It is upwards that a query like 'Xxfoo' is where the match does not occur.
Which is the priority or the better solution?
update
MySQL 5.6 Later, InnoDB supports tables against matching ... against .
The first lot will use the full text index against those columns on the better MyISAM tables. Second, one is contacting every line and after that a full table will scan.
Likes only if you are against it:
- There is no result of a column (function, unless your specific database The vendor does not support the functional index - for example - Oracle - and you are using them);
- The beginning of the column (like
as opposed to 'Blah%'as'% blah%'); - is a indexed column.
If none of those conditions is true then the only way to execute the query to the SQL engine is to scan the whole table. It can be useful under approximately 10-20 thousand rows
Note: There is a problem with MATCH on MySQL that it seems that matches only with full words Therefore, 'bla' will not be searched for a column with the values of 'bla', but will be searched for 'bla *'.
Comments
Post a Comment