Closed mchehab closed 2 weeks ago
It turns that there's no index for hashes there:
EXPLAIN SELECT * FROM patchwork_patch where hash='b842eaa572bb99d576c4c9a814c0a7956c07c804';
+------+-------------+-----------------+------+---------------+------+---------+------+-------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-----------------+------+---------------+------+---------+------+-------+-------------+
| 1 | SIMPLE | patchwork_patch | ALL | NULL | NULL | NULL | NULL | 49917 | Using where |
+------+-------------+-----------------+------+---------------+------+---------+------+-------+-------------+
1 row in set (0.001 sec)
After manually running:
CREATE INDEX idx_patch_hash on patchwork_patch (hash);
The issue was fixed:
SELECT id FROM patchwork_patch where hash='b842eaa572bb99d576c4c9a814c0a7956c07c804';
+-------+
| id |
+-------+
| 98147 |
+-------+
1 row in set (0.002 sec)
EXPLAIN SELECT * FROM patchwork_patch where hash='b842eaa572bb99d576c4c9a814c0a7956c07c804';
+------+-------------+-----------------+------+----------------+----------------+---------+-------+------+-----------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-----------------+------+----------------+----------------+---------+-------+------+-----------------------+
| 1 | SIMPLE | patchwork_patch | ref | idx_patch_hash | idx_patch_hash | 121 | const | 1 | Using index condition |
+------+-------------+-----------------+------+----------------+----------------+---------+-------+------+-----------------------+
1 row in set (0.001 sec)
It seems that somewhere at Django model, a hash index is needed.
Patch submitted here.
This happens via pwclient and using curl: