
March 3rd, 2003, 03:02 AM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 7
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
GROUP BY performance
A common task is to do listing of subjects and the number of replies/comments/ whatever associated with every subject..
lets say forum topic and the number of posts in every topic..
if you want something in this way:
'topic1' 314
'topic2' 54
'topic3' 432
then you can do something like....
SELECT forum.name,
COUNT(*) AS no_of_replies
FROM forum
INNER JOIN forum_reply ON forum_reply.f_id = forum.id
GROUP BY forum.name
however I find this type of query to be very slow if you have a lot of rows, even with proper indexing used...
is there any other way you guys usually do it..?
sub queries are an option in SQL server for example but not in mySQL as I understand
|