nice work, Jesse:
you may want to do some benchmarking using:
EXPLAIN SELECT
M.username AS `admin_username`,
M.photo_filename AS `c.photo_filename`,
C.`author_id` AS `c.author_id`,
C.`comment` AS `c.comment`,
C.`name` AS `c.name`,
C.comment_date AS `c.date`,
CH.author_id AS `ct.author_id`,
CH.channel_id AS `ct.channel_id`,
CH.entry_id AS `ct.entry_id`
FROM exp_members M
INNER JOIN exp_channel_titles CH ON M.member_id = CH.author_id
INNER JOIN exp_comments C ON CH.entry_id = C.entry_id
WHERE M.username = 'random_user_name_here'
AND CH.channel_id = 4
AND (CH.`status` = 'Open' OR CH.`status` = 'open')
ORDER BY `c.date` DESC
LIMIT 5
If you run:
show create table exp_members;
You’ll notice there isn’t an index on the username, so you *might* get a bit more mileage if you select the member_id from exp_members where username = ‘blah’ first, then use the result of that in the big query. Make sense?
So you’ve written a hard query, now comes the fun part, tuning it 😉
-greg