The Limbo World Championships have called you in to optimise their scoreboard for performance.
On inspecting the homepage, you notice that it is suboptimal, executing 62
database queries and populating 28
elements, when you can plainly see that only 18
unique elements are actually displayed on the scoreboard. Also, as the number of competitors increases, so do the number of queries and elements, meaning that the code has a complexity of O(n).
There’s no time to lose. Your task is to bring the complexity of the queries under control and reduce the number of database queries executed and elements loaded as much as humanly possible. There have been murmurs in the limbo community of a rising star that has managed to achieve the coveted 35
(database queries), but this is yet to be confirmed.
This GitHub repo contains the Craft CMS site that you can spin up with a single command, either locally or in the browser using a GitHub codespace (see the readme file in the repo). Once you are set up, log into the CP as the admin
user, visit the front-end URL, open the debug toolbar and then get to work!
Your solution should consist of an optimised version of the templates/index.twig
template, along with mentioning the number of database queries executed and elements loaded.
templates/index.twig
template. body
block, but doing so shouldn’t be necessary or even helpful.admin
user with the debug toolbar enabled.Eager-load all the things and leverage Twig filters to help avoid queries.