Hi !
Imagecrop schema need some indexes.

Mysql slow log show always the same request :

mysql> explain SELECT xoffset,yoffset,width,height,scale FROM imagecrop ic INNER JOIN files f on f.fid = ic.fid WHERE f.filepath = 'sites/default/files/article/388/main-image/image3.jpg' AND ic.presetid = 5 AND reference = 'files';
+----+-------------+-------+--------+---------------+---------+---------+--------------------+------+-------------+
| id | select_type | table | type   | possible_keys | key     | key_len | ref                | rows | Extra       |
+----+-------------+-------+--------+---------------+---------+---------+--------------------+------+-------------+
|  1 | SIMPLE      | ic    | ALL    | NULL          | NULL    | NULL    | NULL               |    6 | Using where | 
|  1 | SIMPLE      | f     | eq_ref | PRIMARY       | PRIMARY | 4       | milanor_dev.ic.fid |    1 | Using where | 
+----+-------------+-------+--------+---------------+---------+---------+--------------------+------+-------------+
2 rows in set (0.00 sec)

adding an index on presetid solve this :

mysql> alter table imagecrop add index presetid(presetid);
Query OK, 6 rows affected (0.00 sec)
Records: 6  Duplicates: 0  Warnings: 0

mysql> explain SELECT xoffset,yoffset,width,height,scale FROM imagecrop ic INNER JOIN files f on f.fid = ic.fid WHERE f.filepath = 'sites/default/files/article/388/main-image/image3.jpg' AND ic.presetid = 5 AND reference = 'files';
+----+-------------+-------+--------+---------------+----------+---------+--------------------+------+-------------+
| id | select_type | table | type   | possible_keys | key      | key_len | ref                | rows | Extra       |
+----+-------------+-------+--------+---------------+----------+---------+--------------------+------+-------------+
|  1 | SIMPLE      | ic    | ref    | presetid      | presetid | 4       | const              |    1 | Using where | 
|  1 | SIMPLE      | f     | eq_ref | PRIMARY       | PRIMARY  | 4       | milanor_dev.ic.fid |    1 | Using where | 
+----+-------------+-------+--------+---------------+----------+---------+--------------------+------+-------------+
2 rows in set (0.00 sec)

Can you please modify your schema to have an index on preset id.

Great module by the way !

Comments

nils.destoop’s picture

I already noticed it a while ago.
In the dev version, there is an update hook that adds the indexes.

But i noticed i forgot to update the schema

nils.destoop’s picture

Status: Active » Fixed

added also in the schema

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.