For further speed up the Random image, I modified the password protected album by SQL instead of check the album tree node one by one. I have already created the ticket, but want to discuss more in forum.
The time of getting 9 random images on a 4500 images and 300 albums gallery.
use getRandomImages: 4.88 sec improved to 2.36 sec
use getRandomImagesAlbum(from root album): 24.07 sec improved to 2.63 sec
some concern.
1 It just filter all password protected album or don't filter for loggined user, because not a album and album checking, but I think it is not important for showing a random images.
2 I am not sure did the php-mysql library got limitation on query string buffer, since the length of SQL where clause maybe longer and longer if the number of albums growth. Although it can use the sub-query for filtering, I feel mysql is not doing very well on handing sub-query after a test of speed. So, I gave up to use subquery.
3 It use a outer join for getting a tree. The join process may be slower when the level of tree growth.
Comments