After Shawn's guidance, I tried inserting with the temporary table method
using this:
CREATE TEMPORARY TABLE tmpStats (KEY(product_id))
SELECT TP.thread_id, COUNT(TP.thread_id) AS num_posts, MAX(TP.post_date) AS
last_update
FROM thread_post AS TP
INNER JOIN thread_link AS TL ON TP.thread_i
Thanks Shawn, I'm going to give the temporary table idea a try.
I did omit the 'category' table while testing but when I used EXPLAIN the # of rows
for the thread_link join increased from 105 to 16326 so I decided to leave the
category table in. But I agree, it isn't needed.
My other idea I ha
I know you said this was a translation of your original query. Assuming
that it is a faithful translation, I have the following suggestions:
Do not enclose numbers with quotes (category_id is a number, right? No
quotes are needed)
You do not need include the table "category" in this query. You
I'm having a bit of a problem with a query that takes a very long time (up to 1
minute) when many matching rows are found.
The tables are all indexed and the explain seems to indicate that mysql is using the
indexes but it is still painfully slow:
mysql> SELECT COUNT(TP.thread_id) AS num_posts,