Closed (fixed)
Project:
Buddylist
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Mar 2007 at 00:16 UTC
Updated:
8 Jul 2007 at 17:46 UTC
Even when buddylist groups are not enabled, the function buddylist_get_buddies queries the groups table. On friends based social networking site, this can result in a lot of unnecessary load on the db.
I'm attaching a patch. Since my site's not using groups, I haven't tested to see how this works if you have groups turned on. The logic seems sound, but be sure to test first.
| Comment | File | Size | Author |
|---|---|---|---|
| buddylist.module_3.patch | 567 bytes | gwen |
Comments
Comment #1
stroobl commentedWe implemented this patch and the performance gain is huge. It can save you hundreds of SQL queries for every pageview.
In addition to the above patch, we also added a check to make sure buddylist queries are only executed when somebody is on a profile/buddylist page. Buddylist was checking buddy info for every article poster, while that info was displayed nowhere in our situation (maybe it's usefull in some cases, I'm not sure about that). But when you have an index-page with ten or more posts and the posters have lot's of buddies, that's really painfull.
This is what we changed:
671c671
< if (!isset($buddies[$key][$uid])) {
---
> if (!isset($buddies[$key][$uid]) && (arg(0) == 'buddy' || arg(0) == 'buddylist' || arg(0) == 'user') ) {
681,682c681,684
< $buddies[$key][$uid][$row->buddy]['groups'] = buddylist_get_buddy_groups($uid, $row->buddy);
< $buddies[$key][$uid][$row->buddy]['online'] = 0;
---
> if (variable_get('buddylist_buddygroups', FALSE)) {
> $buddies[$key][$uid][$row->buddy]['groups'] = buddylist_get_buddy_groups($uid, $row->buddy);
> }
> $buddies[$key][$uid][$row->buddy]['online'] = 0;
828c830
And the result:
Index-page before:
Executed 968 queries in 638.08 milliseconds.
Page execution time was 1719.58 ms.
After patch:
Executed 434 queries in 78.85 milliseconds.
Page execution time was 724.56 ms.
Profile-page of a user with lot's of buddies before:
Vorige week donderdag:
Executed 3636 queries in 477.09 milliseconds.
Page execution time was 1380.71 ms.
After patch:
Executed 411 queries in 133.83 milliseconds.
Page execution time was 733.8 ms.
Comment #2
robertdouglass commented@gwen, thanks, fixed.
@lstroobant, please open another issue and provide a patch file.
@both please make diffs using the -u flag for readability. Thanks.
Comment #3
(not verified) commented