2025/11/24#p1
I spent some time looking at the database queries triggered by the blog page and how I could optimise them. I know, exciting stuff!
There were some similar queries which I was able to condense by only running the larger and processing the results to get the relevant subset rather than making separate queries. By moving a couple, I was able to avoid repeated calls and use the same result in multiple places.
The way the code was structure very much reflected the way it was built — piecemeal, focusing on each function as a separate process, instead of holistically. I'm surprised it's taken nearly five years for me to address this.
With some help from ChatGPT and bashing my head against the wall, I also managed to streamline the way comments (and replies to comments) into a single query with a bit of logic to separate them out for display.
Much better.