Download & Extend

Avoid unnecessary queries in vud_widget_proxy()

Project:Vote Up/Down
Version:6.x-3.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:catch
Status:closed (fixed)
Issue tags:Performance

Issue Summary

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.

AttachmentSizeStatusTest resultOperations
user_votes.patch488 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch user_votes.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.View details

Comments

#1

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.

#2

#3

Title:Unnecessary queries in vud_widget_proxy()» Avoid unnecessary queries in vud_widget_proxy()
Status:postponed» needs review

+++ 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.

AttachmentSizeStatusTest resultOperations
0001-bug-962996-by-catch-marvil07-Avoid-unnecessary-queri.patch3.15 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 0001-bug-962996-by-catch-marvil07-Avoid-unnecessary-queri.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.View details

#4

a little addition: fix documentation.

AttachmentSizeStatusTest resultOperations
0001-bug-962996-by-catch-marvil07-Avoid-unnecessary-queri-v2.patch4 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 0001-bug-962996-by-catch-marvil07-Avoid-unnecessary-queri-v2.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.View details

#5

Status:needs review» fixed

Ok, committed to 3.x.

#6

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

#7

Status:fixed» closed (fixed)

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

nobody click here