Today I played a bit with my [fotoalbum](/development/fotoalbum/). I learned that I made a whole **lot** of database queries which are not necessary at all. So I began making optimisations to improve performance.
After adding a query counter and looking at some queries and code I found out how to improve the behaviour given. The thing that created most of the queries (>60%) was the recursive function *isPublished()*. But this function is needed to successfully tell if an image is published or not. So what to do? Use caching!
The cache did a good job, but could not reduce the number of queries the way I wanted it to be. So I tried harder on optimising queries, loops and object creation.
Finally I could gain a reduction of about **93%** of the queries made when it was not optimised at all. This is great, you know, because an image gallery should not eat that much server performance.
Well, go to [my installation of fotoalbum](/fotoalbum/) if you’d like to see it in action. If you like it, then you can also [get a copy](/download/) of it! If something fails then please report it to [the fotoalbum page](/development/fotoalbum/) so I can help you or at least fix the problem.