Translate-plugin: Eager loading attributes

Created on 30 Jul 2019  路  8Comments  路  Source: rainlab/translate-plugin

Currently the plugin issues a new SQL query for each items in a collection to fetch the data from rainlab_translate_attributes table.

For example if I have a collection with 3 items of H3Kft\Pcd\Models\Woa (with id's if 1, 2, 3) and want to get the "hu" translations this will result in 3 separate queries:

select * from rainlab_translate_attributes where locale = 'hu' and model_id = 1 and model_type = 'H3Kft\Pcd\Models\Woa' limit 1

select * from rainlab_translate_attributes where locale = 'hu' and model_id = 2 and model_type = 'H3Kft\Pcd\Models\Woa' limit 1

select * from rainlab_translate_attributes where locale = 'hu' and model_id = 3 and model_type = 'H3Kft\Pcd\Models\Woa' limit 1

instead I think it would be ideal to execute one query:

select * from rainlab_translate_attributes where locale = 'hu' and model_id in (1, 2, 3) and model_type = 'H3Kft\Pcd\Models\Woa'

This would result in a major performance boost for non default languages.

I would be happy to offer bounty for such an improvement, i think others would join, as this is now a major bottleneck in performance of multilingual sites.

Completed Enhancement bounty

Most helpful comment

Hi guys, i've just developed this feature in a very simple way.
It seems to work well. Please test it and let me know
https://github.com/rainlab/translate-plugin/pull/504

All 8 comments

@hirisov We would definitely appreciate any bounties you and others are willing to offer to get the feature implemented. Feel free to post a bounty here: https://www.bountysource.com/issues/77949687-eager-loading-attributes

Thanks for creating the bounty, i backed it up. I hope others will join! :)

馃憤

A3Emanuele Bucciarelli notifications@github.com ezt 铆rta (2019. aug. 1. 9:40):馃憤

鈥擸ou are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

It would be a very appreciated improvement!

Hi guys, i've just developed this feature in a very simple way.
It seems to work well. Please test it and let me know
https://github.com/rainlab/translate-plugin/pull/504

@massimomegistus did you pickup the bounty on this?

@mjauvin not yet. I'm going to try :)

Was this page helpful?
0 / 5 - 0 ratings