The table piwigo_images needs an index on the field path in order to remove table scans when looking for images that are locally synchronised. I looked at Mysql query performance on Mariadb and found lots of first row and table scan warnings in the performance logs, due to Select * from piwigo_images where path=''
My server is a quad core and each image would spike to 240% CPU load in Mysql when fetched by the browser at the API GET /_data/i/galleries/
adding an index to the path field on this table resulted in a 200% reduction in load, and a massive speed up in image retrieval.
The table piwigo_images needs an index on the field path in order to remove table scans when looking for images that are locally synchronised. I looked at Mysql query performance on Mariadb and found lots of first row and table scan warnings in the performance logs, due to Select * from piwigo_images where path='<absolute path of local image>'
My server is a quad core and each image would spike to 240% CPU load in Mysql when fetched by the browser at the API GET /_data/i/galleries/<image name>
https://github.com/Piwigo/Piwigo/blob/a641b9eb08650272b3bf8f9e9db92ffd3e529d1f/install/piwigo_structure-mysql.sql#L215
adding an index to the path field on this table resulted in a 200% reduction in load, and a massive speed up in image retrieval.
<!-- github-sync-id:770192915 -->
I've made some test with a 1 million lines piwigo_images table. On average, the select ... where path=... query takes 0.900 seconds on my rather slow old computer. It's absolutely huge.
With the index ALTER TABLE piwigo_images ADD INDEX images_i7 (path); the same queries take less than 0.001 second. That's 900 times faster.
This index will obviously improve performances with big images tables.
Hi @andyleadbetter
I've made some test with a 1 million lines `piwigo_images` table. On average, the `select ... where path=...` query takes 0.900 seconds on my rather slow old computer. It's absolutely huge.
With the index `ALTER TABLE piwigo_images ADD INDEX images_i7 (path);` the same queries take less than 0.001 second. That's 900 times faster.
This index will obviously improve performances with big images tables.
<!-- github-comment-id:748100834 -->
32 seconds in huge during the upgrade procedure. I hope the upgrade page won't finish as timed out.
The only problem I see is the time to create this index.
```
mysql> ALTER TABLE piwigo_images ADD INDEX `images_i7` (`path`);
Query OK, 960171 rows affected (32.45 sec)
Records: 960171 Duplicates: 0 Warnings: 0
```
32 seconds in huge during the upgrade procedure. I hope the upgrade page won't finish as timed out.
<!-- github-comment-id:748104440 -->
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.
The table piwigo_images needs an index on the field path in order to remove table scans when looking for images that are locally synchronised. I looked at Mysql query performance on Mariadb and found lots of first row and table scan warnings in the performance logs, due to Select * from piwigo_images where path=''
My server is a quad core and each image would spike to 240% CPU load in Mysql when fetched by the browser at the API GET /_data/i/galleries/![]()
https://github.com/Piwigo/Piwigo/blob/a641b9eb08650272b3bf8f9e9db92ffd3e529d1f/install/piwigo_structure-mysql.sql#L215
adding an index to the path field on this table resulted in a 200% reduction in load, and a massive speed up in image retrieval.
Hi @andyleadbetter
I've made some test with a 1 million lines
piwigo_imagestable. On average, theselect ... where path=...query takes 0.900 seconds on my rather slow old computer. It's absolutely huge.With the index
ALTER TABLE piwigo_images ADD INDEX images_i7 (path);the same queries take less than 0.001 second. That's 900 times faster.This index will obviously improve performances with big images tables.
The only problem I see is the time to create this index.
32 seconds in huge during the upgrade procedure. I hope the upgrade page won't finish as timed out.