We've got a pretty large forum. After about 4 months of having the thanks hack installed (and trimmed down so it's basically a "like" button for posts), we have about 1.45 million rows in our dbtech_thanks_entry table.
I've had to add quite a few indexes to keep things speedy, but I have one final (hopefully) query that's absolute murder: The query when people visit the Hottest posts/threads page.
I've indexed it to the best of my ability, but it's still scanning 700,000 rows, writing to a temporary table, and doing a filesort. Even on the beefy system we're running, it takes around 10 seconds.
Fortunately the page isn't hit very often, but it has caused a few issues when piled on top of other problems. Is there an easy way to disable the "hottest threads" page? I couldn't find a switch or anything to disable it.
Also, in case you're wondering what I've done to the dbtech_thanks_entry table, aside from converting it to InnoDB, here's a full list of the indexes:
(It's probably overkill but I error on the side of INDEX ALL THE THINGS!)
I've had to add quite a few indexes to keep things speedy, but I have one final (hopefully) query that's absolute murder: The query when people visit the Hottest posts/threads page.
Code:
# Query_time: 14.674804 Lock_time: 0.000077 Rows_sent: 25 Rows_examined: 4914866 Rows_affected: 0 Rows_read: 4914866
# Bytes_sent: 6424
SET timestamp=1368192326;
SELECT
COUNT(*) AS entrycount,
post.title AS posttitle,
thread.title AS threadtitle,
thread.title AS title,
post.postid,
thread.forumid
FROM dbtech_thanks_entry AS entry
LEFT JOIN post AS post ON(post.postid = entry.contentid)
LEFT JOIN thread AS thread ON(thread.threadid = post.threadid)
WHERE contenttype = 'post'
AND varname = 'likes'
GROUP BY entry.contentid
ORDER BY entrycount DESC
LIMIT 25;
I've indexed it to the best of my ability, but it's still scanning 700,000 rows, writing to a temporary table, and doing a filesort. Even on the beefy system we're running, it takes around 10 seconds.
Fortunately the page isn't hit very often, but it has caused a few issues when piled on top of other problems. Is there an easy way to disable the "hottest threads" page? I couldn't find a switch or anything to disable it.
Also, in case you're wondering what I've done to the dbtech_thanks_entry table, aside from converting it to InnoDB, here's a full list of the indexes:
Code:
mysql> show indexes from dbtech_thanks_entry;
+---------------------+------------+----------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+---------------------+------------+----------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| dbtech_thanks_entry | 0 | PRIMARY | 1 | entryid | A | 1394059 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | entryid | 1 | userid | A | 30979 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | entryid | 2 | entryid | A | 1394059 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | entryid_2 | 1 | receiveduserid | A | 77447 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | entryid_2 | 2 | entryid | A | 1394059 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | receiveduserid | 1 | receiveduserid | A | 77447 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | userid | 1 | userid | A | 60611 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | userid_2 | 1 | userid | A | 58085 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | userid_2 | 2 | contenttype | A | 60611 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | userid_2 | 3 | dateline | A | 1394059 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | entryid_3 | 1 | varname | A | 18 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | entryid_3 | 2 | contenttype | A | 18 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | entryid_3 | 3 | entryid | A | 1394059 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | contenttype | 1 | contenttype | A | 18 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | contenttype | 2 | contentid | A | 1394059 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | varname | 1 | varname | A | 18 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | varname | 2 | contenttype | A | 18 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | varname | 3 | contentid | A | 1394059 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | contenttype_2 | 1 | contenttype | A | 18 | NULL | NULL | | BTREE | | |
| dbtech_thanks_entry | 1 | contenttype_2 | 2 | dateline | A | 1394059 | NULL | NULL | | BTREE | | |
+---------------------+------------+----------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
20 rows in set (0.06 sec)
Last edited: