Nested Template Queries
While nested templates have been a great innovation in efficiently writing pages, they seem to have some inefficiency in parsing pages. Articles attempt to fetch the replacement text for all templates at once using only one query. However, the parser cannot determine the replacement text that will be needed to parse nested templates, without first parsing the replacement text for the first templates. This means that for every level of nested templates, there is one query. A second/third/fourth/etc level template creates new branches of templates, which are then multiplied into the queries needed. For some articles, templates could be adding 9 or 10 queries, or more.
For the next build, we have added a new caching mechanism to deal with this issue. Basically, when a page using templates is parsed, it saves the ids of the templates it needed into its metadata. Next time around, it fetches all of the expected templates at once, rather than waiting for each branch to parse to find out.
Even so, keep template code as simple as possible. Try not to nest too many templates, because your server will have to run 50 queries at least once to create the metadata.