If your photo gallery contains 1 million photos, the current (11.3) algorithm to calculate the storage space used by each kind of files (photos/videos/formats/other) will reach memory limit.
Furthermore, there is no need to calculate the sum in the PHP. The database can do it, more efficiently.
On my test database with 960k photos, it takes 800ms to fetch all individuals photos and 4000ms to generate the whole page. With an aggregation query, the SQL takes 1700ms (that's longer) but the page generates in 3000ms (that's faster). Here is the aggregation query I used to test:
$query = '
SELECT
SUBSTRING_INDEX(path,".",-1) AS ext,
SUM(filesize) AS filesize
FROM `'.IMAGES_TABLE.'`
GROUP BY ext
;';
$file_extensions = query2array($query, 'ext', 'filesize');
Even optimized, it takes too much time in my opinion. Next step would be to cache this.
If your photo gallery contains 1 million photos, the current (11.3) algorithm to calculate the storage space used by each kind of files (photos/videos/formats/other) will reach memory limit.
Furthermore, there is no need to calculate the sum in the PHP. The database can do it, more efficiently.
On my test database with 960k photos, it takes 800ms to fetch all individuals photos and 4000ms to generate the whole page. With an aggregation query, the SQL takes 1700ms (that's longer) but the page generates in 3000ms (that's faster). Here is the aggregation query I used to test:
```
$query = '
SELECT
SUBSTRING_INDEX(path,".",-1) AS ext,
SUM(filesize) AS filesize
FROM `'.IMAGES_TABLE.'`
GROUP BY ext
;';
$file_extensions = query2array($query, 'ext', 'filesize');
```
Even optimized, it takes too much time in my opinion. Next step would be to cache this.
<!-- github-sync-id:808627955 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
If your photo gallery contains 1 million photos, the current (11.3) algorithm to calculate the storage space used by each kind of files (photos/videos/formats/other) will reach memory limit.
Furthermore, there is no need to calculate the sum in the PHP. The database can do it, more efficiently.
On my test database with 960k photos, it takes 800ms to fetch all individuals photos and 4000ms to generate the whole page. With an aggregation query, the SQL takes 1700ms (that's longer) but the page generates in 3000ms (that's faster). Here is the aggregation query I used to test:
Even optimized, it takes too much time in my opinion. Next step would be to cache this.
Fixed in
370ba45on master andeab9d44on 11.x