• Welcome to PHPVIBE Forums. Please log in.

[ Video Sharing CMS v4 ] use MATCH AGAINST instead of LIKE '%$key%'

Started by dtiberio,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dtiberioTopic starter

don't do database searches this way, it is too slow. the % sign at the beginning of a match requires the db to search through everything.

instead use the MATCH....AGAINST feature with a full text index. it will make the database much much faster. this should be a high priority change to your system. the %$key% method will have a huge performance hit on your database.

WHEN ".DB_PREFIX."videos.description like '%" .$key. "%'

I think it is written MATCH (videos.description) against ($key), not sure. and you have to have that full text index. I think the command is:

alter table vibe_videos add fulltext description_ft (description);

only add the FT index once and never again, other wise it will add it multiple times and it will be slower.
  •  

dtiberioTopic starter

this is okay:

where title like '$key%'

however this is very slow and resource intensive:

where title like '%$key%'
  •  

dtiberioTopic starter

and in both cases you need to have indexes.

so '%$key% and '$key%' might be the same without indexes, but '$key%' is much faster like 100x faster with indexes.
  •  

PHPVibe A.

We did this in 3.1 (or 3.3) and everybody complained about the results.

dtiberioTopic starter

did you use Booleans?

the fact is that you can't use the '%$key%' matching on a large database. it will become slow.
  •  

PHPVibe A.

We did it by the book, if you have other suggestion besides match, we are really looking for one ourselves.

Similar topics (7)