I am trying to pull up search results on a large database of products. Ideally I'd like to display 3 or 4 items for each category with a "See all XXX matches in category Y" after each category. I also use the number of matches within each category to output the categories by the number of matches.
That said, I decided to run a MATCH/AGAINST query on each category and use SQL_CALC_FOUND_ROWS to get the total results for each category. This allows for the category ordering as well as a message indicating to the user how many matches occured in this category.
However, SQL_CALC_FOUND_ROWS takes WAY too long due to the size of the database. The table that the MATCH/AGAINST query occurs has approx. 4 million rows (there are about 20 categories).
If the SQL_CALC_FOUND_ROWS is taken out and therefore the number of matches per catgory is unknown, the query is executed relatively fast (about 0.7 to 2.0 seconds)
Anyone have any tips,hacks,work-arounds, or alternatives???