Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Themes /

Discuss SilverStripe Themes.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Partial caching to reduce SQL queries?

Go to End

2 Posts   1753 Views


Community Member, 78 Posts

17 July 2013 at 2:48am

Hi ladies,

as mentioned in the docs ( i thought, that using partial caching could also reduce the number of sql queries.

When using

<% cached 'MenuLeft', List(SiteTree).max(LastEdited) %>
		<% loop $Menu(1) %>
			<li class="$LinkingMode"><a href="$Link" title="$Title.XML">$MenuTitle.XML</a></li>
		<% end_loop %>
<% end_cached %>

When i check by using ?showqueries=1 the sql-queries stack is exactly the same?

Confusing (to me) ....


Forum Moderator, 1391 Posts

26 August 2013 at 10:35pm


I'm not sure that this is the case here, because I've seen a some discussions of partial caching not always actually caching... But just a hunch: SilverStripe tries to cache many of its queries and objects along the way, so could it be that menu(1) already uses cached queries in the first place?

I often test these kind of things by placing some echo "*****" in the function involved, say at the start and the end of the function. Kinda simplistic and dirty, I know, (hiding my face) but quick to spot any sql queries executed by that specific function :)