Use fulltext indexes (http://www.mysql.com/doc/F/u/Fulltext_Search.html).
Queries with LIKE '%...%' will always be slow because they can't use
indexes, and you're doing SIX of them, of course it'll take a while. Only
drawback of fulltext indexes is (AFAIK) you can't match against fields in
separate tables in a single fulltext query.
> Hi to all of you!
>
> The following query takes more than half an our to execute. I don't think
> that is normal. Most time takes "copying to tmp table".
>
> SELECT DISTINCT
> Formular.titel AS formularTitel,
> Formular.id AS formularId,
> Anbieter.id AS anbieterId,
> Anbieter.anbieterName AS anbieterName
> FROM
> Formular,
> Anbieter
> WHERE
> Formular.anbieter_id=Anbieter.id
> AND
> ( Formular.titel LIKE '%köln%' OR Formular.schluesselwoerter LIKE '%köln%'
> OR Anbieter.anbieterName LIKE '%köln%' )
> AND
> ( Formular.titel NOT LIKE '%gew%' AND Formular.schluesselwoerter NOT LIKE
> '%gew%' AND Anbieter.anbieterName NOT LIKE '%gew%' )
> )
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php