I'm running the most uptodate v5 build on the latest Raspberry Pi OS on a Pi 3b+, and it runs pretty well except for a couple of issues.
When trying to view Long Term Data -> Query Log, I can bring back queries for Today, Yesterday and 7 Days ago however going back further (ie. 30 days, this month...) I'm seeing an Internal Server Error (500) being returned when calling /api_db.php usually after a few seconds (5 or so).
Is there perhaps an issue with the webserver/php timing out too quickly?
No, this is likely not a timeout but hitting a memory limit. Search the forum for PHP memory. There are dozens of posts with details how to fix this and also why this limitation exists. I think they are working on overhauling this with Pi-hole v6.0, but I'm not sure about this.