このクエリの機能するインデックスを作成し、「ファイルソート」を取り除く方法はありますか?
SELECT id, title FROM recipes use index (topcat) where
(topcat='$cid' or topcat2='$cid' or topcat3='$cid')
and approved='1' ORDER BY id DESC limit 0,10;
インデックス "topcat" (列: topcat1+topcat2+topcat3+approved+id) を作成しましたが、まだ "Using where; Using filesort" を使用しています。
もう 1 つの列を作成できます。たとえば、「all_topcats」を作成して、配列に topcat 番号を格納し、1,5,7 にしてから、クエリ「... where $cid iIN ()...」を実行します。しかし問題は、この場合、「all_topcats」列は「varchar」になりますが、「承認済み」列と「id」列は int になり、いずれにせよインデックスは使用されないということです。
何か案は?ありがとう。