…d file Use Config to retrieve the variable instead of trying to access it directly, and failing.
Pre-filter the sub-select of Post in these queries, which massively improves performance on large Post tables. Add indexes to ForumThread as well which helps across the board.
It relies on a write to Member.LastViewed on every request for a logged in forum Member, which can be database blocking if forum traffic is high.
Just use the Group_Members table to find the latest MemberID. This also makes it work in databases that don't support RIGHT JOIN.
…e folders which are not as robust
Uses a more efficient aggregate query, to avoid the database having to do a filesort on a temporary table because of joining and sorting. Using RIGHT JOIN in this case appears to be faster, so had to drop back to straight up SQL instead of using the ORM. On large Member tables, this reduces the querying from ~400ms in one to around ~60ms in two (one to get the max ID, and another to fetch the Member record by ID) Also removed the administrators group from the query. I don't see why you'd want to see the latest administrator join the site.
DataQuery always adds DISTINCT to queries, but this slows things down when performing queries against large amounts of data. In those cases, we also don't need to be checking distinct.