DoctrineExtensions
DoctrineExtensions copied to clipboard
[Translatable] Performance problems due to foreign key type
I recently started using Translatable and I had massive performance problems on MySQL 5.7 until I realized that foreign_key
of the translation tables is not the same type as the id
field of my entity tables (varchar <->integer). For some weird reason, this problem only occured when joining the same translation table more than once (i.e. more than one field was marked as translatable).
I would assume there are many users with non-varchar IDs, so it might be a good idea to mention that somewhere in the docs.
The duration of one of my queries decreased from 8000ms (!) to 60ms after changing the foreign_key
type.
@stiefn Thanks for your issue! I had the same problem - my query went from 4000ms to 5ms.
@stiefn How did you change the foreign_key type of the default table?
Create an entity that extends AbstractTranslation and override the field. Then use this abstract entity to extend your translation entities.
I had this problem too but for some reason extending AbstractTanslation and just overriding the field foreignKey didn't helped, I had to override table name too (with original table ext_translations still created).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.