You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update and delete executors for Class Table Inheritance (JOINED) are extremely slow on MySQL platform. It is most probably due to use of subselect on the temporary table.
The slowdown is really significant as the table size increases. As an example, lets have a root entity with one subclass:
UPDATE Entities\Root r SET r.xyz = 123 WHERE r.id > ?
(note: always the upper half of entries)
Which creates following SQLs:
CREATE TEMPORARY TABLE Root*id*tmp (id INT NOT NULL)
INSERT INTO Root*id_tmp (id) SELECT t0.id FROM Root t0 LEFT JOIN SubA s0_ ON t0.id = s0*.id WHERE t0.id > 25000
UPDATE Root SET xyz = 123 WHERE (id) IN (SELECT id FROM Root*id*tmp)
DROP TEMPORARY TABLE Root*id*tmp
The time spent on this on MySQL 5.5.17 and PostgreSQL 9.1 is:
As you can see, MySQL is drastically slower on even relatively small tables. This currently makes Doctrine unusable for this type of inheritance on MySQL. The solution probably would be to avoid subselect in WHERE clause in Doctrine\ORM\Query\Exec\MultiTableUpdateExecutor and Doctrine\ORM\Query\Exec\MultiTableDeleteExecutor.
Feel free to try/modify the test script yourself, it's here.
The text was updated successfully, but these errors were encountered:
Changing this would be an improvement where we would hint if databases prefer subselects or joins for different operations. This would increase complexity of the SQL generation since now we are getting along with just one SQL generation strategy.
Jira issue originally created by user majkl578:
Update and delete executors for Class Table Inheritance (JOINED) are extremely slow on MySQL platform. It is most probably due to use of subselect on the temporary table.
The slowdown is really significant as the table size increases. As an example, lets have a root entity with one subclass:
Now lets perform a simple DQL UPDATE:
(note: always the upper half of entries)
Which creates following SQLs:
The time spent on this on MySQL 5.5.17 and PostgreSQL 9.1 is:
|| no. of entries || 500 || 1000 || 2500 || 5000 || 10000 || 20000 || 50000 ||
| MySQL | 0.26s | 0.35s | 1.1s | 3.68s | 14.13s | 54.44s | 338s |
| PostgreSQL | 0.10s | 0.10s | 0.13s | 0.15s | 0.22s | 0.35s | 1.01s |
As you can see, MySQL is drastically slower on even relatively small tables. This currently makes Doctrine unusable for this type of inheritance on MySQL. The solution probably would be to avoid subselect in WHERE clause in Doctrine\ORM\Query\Exec\MultiTableUpdateExecutor and Doctrine\ORM\Query\Exec\MultiTableDeleteExecutor.
Feel free to try/modify the test script yourself, it's here.
The text was updated successfully, but these errors were encountered: