We are using views in a very dynamic way. The attached patch adds some static caching in various places. Together, this tiny patch removed about 15 queries per page for us.

CommentFileSizeAuthor
patch49.patch994 bytesm3avrck

Comments

merlinofchaos’s picture

This should use array_key_exists rather than a separate $cache_null variable.

Why would views_get_all_urls ever be called more than once on a page?

m3avrck’s picture

You know I was working on it all morning and I'm not exactly sure. This patch might be specific to how we're using views.

We have a view setup: community/$arg/node-type

But we dynamically change that and add filters using the views hooks. Because of this, and the fact that we programatically provide default views, something wasn't being cached. Looking at the code, that single query there was executing more than once since we were reusing a view twice on a page (although it ran 3 times, go figure).

Like I said, this might be an issue that just applies to us. But I figured I'd put it out there for anyone that is interested.

Since Views 1.x is on the way out this was our quick fix :)

sun’s picture

Status: Needs review » Needs work

This looks quite interesting, but I think we can assign something faster here:

$cache_null = $which .'-'. $arg;
esmerel’s picture

Status: Needs work » Closed (won't fix)

No changes being made to 1.x. I'd leave it in 'needs review' if the patch was ready, but.

esmerel’s picture

No changes being made to 1.x. I'd leave it in 'needs review' if the patch was ready, but.