Bug #22193
closed
Inefficient fetch of templates from table sys_template
Added by Alexander Weggerle over 14 years ago.
Updated over 13 years ago.
Description
Every basic template which is included in another template is fetched with a single database query.
So on sites which includes many additional templates in the root template this could be a performance bottleneck.
I attached a patch which fetches all the needed templates with one query.
For the testet site the patch gives an performance boost from 40 requests/s before to 62 requests/s after.
The site includes about 30 basic templates into the root template, which is rather unusual. So i don't think the performance enhancement will be so big on typical sites.
(issue imported from #M13669)
Files
nice catch!
at least from reading there is at least one problem: the previous way takes care about the order of the templates. your patch doesn't!
IMO you need to first create an array as the $basedOnArr and then collect the sys_templates in a 2nd array and then you can run through the $basedOnArr and fetch the according templates from the 2nd array. I hope this is understandable.
Ah, you're right. I missed that issue!
I attached a new patch sys_templates_2.diff which considers the sorting.
I think it's better to let the SQL-Server sort, and not the application... Correct me, if you think your way is better.
ah, didn't knew that way but I don't know if this works with DBAL.
maybe put it into the dev-list for discussion?
You catched me again. I'm pretty new in the core development and missed also that issue. Postgresql didn't support that SQL feature and it isn't used in the whole typo3-src.
Under this circumstances i decieded to follow your first recommendation. This has also the advantage that the database connection is immediately closed after the rows are fetched.
See: sys_templates_3.diff
loooks good now if you change those things to follow the CGL:
- initilize $subrows as array();
- comments should be above and one tab indented
- the continue should be inside { }
- before a { only a space and no tab
- combining strings with . needs always a space before and after the .
feel free to send _4 to the core list (after checking the rules there) and I hope you are not discouraged by my comments
Thanks for your patience and your help. You don't discouraged me at all.
I attached the 13669_4.diff, which follows the CGL.
committed version2 to trunk (rev. 7086).
- Target version deleted (
4.4.0)
Also available in: Atom
PDF