I've created an alphabetical index of entries in my template. The code I'm using is in the gist below:
It results in a layout like the one in the following image (screenshot only shows "B":
The problem is it takes 704 database queries. If I don't include the category name ("Business People" under the Jeff Bezos entry on the screenshot) that drops to 22.
Is there anything other than caching I can do here?