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.

Files: 
CommentFileSizeAuthor
#4 0001-bug-962996-by-catch-marvil07-Avoid-unnecessary-queri-v2.patch4 KBmarvil07
FAILED: [[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 ]
#3 0001-bug-962996-by-catch-marvil07-Avoid-unnecessary-queri.patch3.15 KBmarvil07
FAILED: [[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 ]
user_votes.patch488 bytescatch
FAILED: [[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 ]

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
StatusFileSize
new3.15 KB
FAILED: [[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 ]
+++ 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

StatusFileSize
new4 KB
FAILED: [[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 ]

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.