I'm trying to figure out if there's a more performant way of getting entries grouped by category.
As you can see, I'm using NSM Categories module. Right now, this costing me 263 queries and 5 seconds of load. If I remove my if statements (only there because we have different markup for the first entry of a category and also spit out an opening ul element), performance increases dramatically using 63 queries in 2 seconds.
Can anyone suggest any improvements? With something so intensive, we'll be using CE Cache anyway but would like to improve even more before we get to that stage.
{exp:nsm_categories:archive
enable="entries"
category_channel_entry_limit="6"
category="3|6|5|1|7|2"
}
<div class="category category--{category_url_title}">
<h3 class="category__title"><a class="category__link" href="/channel/{category_url_title}">{category_name}</a></h3>
{category_channel_entries}
{if {category_channel_entry_count} == '1'}
<div class="category__firstentry relative" style=
"background-image: url(''); background-size: cover;">
<div class="category__overlay absolute"></div><a class="title relative" href="">{title}</a>
<p class="author relative">by {exp:playa:children var_prefix="children" entry_id="{entry_id}" backspace="5"}{children:title}</a> and {/exp:playa:children}</p>
</div>
{/if}
{if {category_channel_entry_count} == '2'}
<ul class="category__entries">
{/if}
{if {category_channel_entry_count} > '1'}
<li class="entry__single">
<a href="/article/{url_title}">{title}</a>
</li>
{/if}
{/category_channel_entries}
</div>
{/exp:nsm_categories:archive}