vud_widget_proxy() issues a number of database queries whether or not the widget used is actually going to use the result or not.

I added a permissions check to confirm whether the user viewing the widget is allowed to vote or not before trying to look up their vote, this saves 90 queries when viewing 90 comments showing the widget.

It looks like some of the other queries could be consolidated or run selectively but can't see a simple way to do this generically.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marvil07’s picture

Title: Unnecessary query in vud_widget_proxy() » Unnecessary queries in vud_widget_proxy()
Status: Needs review » Postponed

Thanks for the patch :-)

Right, we need to use that patch, but, since I also added positives/negatives, I think we can also avoid that queries(2 less queries per widget show ;-)) after #968630: Let widgets modify template variables gets in.. so I hopefully will be providing a patch for this after the other issue is fixed.

marvil07’s picture

Issue tags: +Performance
marvil07’s picture

Title: Unnecessary queries in vud_widget_proxy() » Avoid unnecessary queries in vud_widget_proxy()
Status: Postponed » Needs review
FileSize
3.15 KB
+++ vud.theme.inc	(working copy)
@@ -150,7 +150,7 @@
+  $user_vote = user_access('user vote up/down') ? votingapi_select_single_vote_value($criteria) : 0;

minor typo in the permission name fixed.

As mentioned, this patch only query positives and negatives for upanddown widget, since it is the only place where it is used.

@catch: it would be great if you can take a look at this before committing it, just in case you want to add something.

Powered by Dreditor.

marvil07’s picture

a little addition: fix documentation.

marvil07’s picture

Status: Needs review » Fixed
catch’s picture

Sorry I was away over the weekend, will try to get this reviewed and tested a bit more tomorrow post-commit.

Status: Fixed » Closed (fixed)
Issue tags: -Performance

Automatically closed -- issue fixed for 2 weeks with no activity.