[dw-free] Fix slow active entries query
[commit: http://hg.dwscoalition.org/dw-free/rev/e1764db1ad9e]
Fix slow active entries query
This query was bad. It would, on certain communities with many comments,
take over a minute to run. This causes page timeouts for viewers of those
communities every time someone comments -- very unfortunate.
This commit causes the query to work fast, but it is slightly less accurate.
No private information is exposed (except the fact that comments were
manipulated that you can't see), but that's better than removing the feature
or having the database die.
The better fix is to do some sort of kind of array that gets updated in the
correct cases, but I'm going for quick-and-dirty right now.
Patch by
mark.
Files modified:
Fix slow active entries query
This query was bad. It would, on certain communities with many comments,
take over a minute to run. This causes page timeouts for viewers of those
communities every time someone comments -- very unfortunate.
This commit causes the query to work fast, but it is slightly less accurate.
No private information is exposed (except the fact that comments were
manipulated that you can't see), but that's better than removing the feature
or having the database die.
The better fix is to do some sort of kind of array that gets updated in the
correct cases, but I'm going for quick-and-dirty right now.
Patch by
![[staff profile]](https://www.dreamwidth.org/img/silk/identity/user_staff.png)
Files modified:
- cgi-bin/DW/Logic/LogItems.pm
-------------------------------------------------------------------------------- diff -r 9b8ff189d7aa -r e1764db1ad9e cgi-bin/DW/Logic/LogItems.pm --- a/cgi-bin/DW/Logic/LogItems.pm Thu Jun 14 05:05:41 2012 +0000 +++ b/cgi-bin/DW/Logic/LogItems.pm Thu Jun 14 23:36:31 2012 +0000 @@ -615,9 +615,12 @@ # get latest 10 entries that were commented on - we will see whether $remote can view them later # disregard screened and deleted comments when ordering + # NOTE: this used to have AND state NOT IN ('D', 'S') but that was removed because there is no + # index that works for the query in that case. it was taking a long time on large accounts and + # causing database unhappiness. my $entryids = $u->selectcol_arrayref( q{SELECT DISTINCT nodeid FROM talk2 - WHERE journalid = ? AND state NOT IN ('D', 'S') + WHERE journalid = ? ORDER BY jtalkid DESC LIMIT 10}, undef, $u->id ); --------------------------------------------------------------------------------