What are the most common template performance gotchas to avoid?
Avoiding unnecessary DB queries is definitely the main thing to watch out for. Here’s an example that came up recently in support: Someone wanted to display the first 6 Matrix blocks in an entry, outputting them 2 at a time. Initially the template code looked something like this:

{% for block in entry.matrixField.limit(2) %}
    &lt;!-- Get the 1st two items --&gt;
{% endfor %}

{% for block in entry.matrixField.offset(2).limit(2) %}
    &lt;!-- Get the next two items --&gt;
{% endfor %}

{% for block in entry.matrixField.offset(4).limit(2) %}
    &lt;!-- Get whatever's left, not more than 2 --&gt;
{% endfor %}


Rather than doing that, we suggested that all 6 blocks be grabbed up front, and output 2 at a time using Twig’s slice filter:

{% set blocks = entry.matrixField.limit(6) %}

{% for block in blocks|slice(0, 2) %}
    &lt;!-- Get the 1st two items --&gt;
{% endfor %}

{% for block in blocks|slice(2, 2) %}
    &lt;!-- Get the next two items --&gt;
{% endfor %}

{% for block in blocks|slice(4, 2) %}
    &lt;!-- Get whatever's left, not more than 2 --&gt;
{% endfor %}


Remember that you can always see what DB queries are happening in a given request by enabling Dev Mode and checking your browser’s Javascript console, where all DB queries for the current request will be logged, ordered by how long they took. It will also show if the exact same query was run multiple times.