During sitemap generation, all news articles of one archive are loaded at once via Models.
Changing this to pure database queries requires more work or code duplication, since the functions to generate the news or event URL need a Model.
Due to 'load'=>'eager' on the author and pid of tl_news and tl_calendar_events this results in a large memory consumption, since the author and archive/calendar is duplicated in memory for each news entry.
Since the advantages of eagerly loading these related objects are negligible and the disadvantages are potentially huge with growing numbers of news entries, the easiest solution is to just set these relations to lazy.
Then, in the worst case, if you display 100 news entries in your newslist module for example and each of these news entries have a different author you would have 100 additional queries (assuming those authors haven't been loaded elsewhere before). If you only have 5 different authors in total, there would be only 5 addition queries (due to the Model registry).
Comparison: when using 10.000 news entries the peak memory usage would be around 1.4 GiB when loading them all. After these changes the peak memory usage is only around 60 MiB.
See contao/core-bundle#1157
The issue is the following:
Model
s.Model
.'load'=>'eager'
on theauthor
andpid
oftl_news
andtl_calendar_events
this results in a large memory consumption, since the author and archive/calendar is duplicated in memory for each news entry.lazy
.Comparison: when using 10.000 news entries the peak memory usage would be around 1.4 GiB when loading them all. After these changes the peak memory usage is only around 60 MiB.