Permalink
Browse files

Don't gobble RAM by reading every comment header into memory when som…

…eone

wants to look at a user's info.
  • Loading branch information...
1 parent 48b3f55 commit 6fb66d69dc23364a6d394aeeb773b375ed6280ec @jamiemccarthy jamiemccarthy committed Dec 4, 2003
Showing with 10 additions and 2 deletions.
  1. +9 −1 Slash/DB/MySQL/MySQL.pm
  2. +1 −1 themes/slashcode/htdocs/users.pl
@@ -5675,14 +5675,22 @@ sub calcTrollPoint {
sub calcModval {
my($self, $where_clause, $halflife, $minicache) = @_;
+ return undef unless $where_clause;
+
# There's just no good way to do this with a join; it takes
# over 1 second and if either comment posting or moderation
# is reasonably heavy, the DB can get bogged very fast. So
# let's split it up into two queries. Dagnabbit.
+ # And in case we're being asked about a user who has posted
+ # many many comments (or heaven forfend, some bug lets this
+ # method be called for the anonymous coward), put a couple
+ # of sanity check limits on this query.
+ my $min_cid = $self->sqlSelect("MIN(cid)", "moderatorlog") || 0;
my $cid_ar = $self->sqlSelectColArrayref(
"cid",
"comments",
- $where_clause,
+ "cid >= $min_cid AND $where_clause",
+ "ORDER BY cid DESC LIMIT 250"
);
return 0 if !$cid_ar or !@$cid_ar;
@@ -1172,7 +1172,7 @@ sub showInfo {
my $lastjournal = _get_lastjournal($uid);
- $modval = $reader->calcModval("comments.uid = $user->{uid}", $uid_hoursback);
+ $modval = $reader->calcModval("comments.uid = $requested_user->{uid}", $uid_hoursback);
$trollpoint = $reader->calcTrollPoint("uid");
slashDisplay('userInfo', {

0 comments on commit 6fb66d6

Please sign in to comment.