Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to reduce excessive number of queries #2369

Merged
merged 2 commits into from
Nov 19, 2023

Conversation

bonroyage
Copy link
Contributor

Description

In many of our projects, we use settings quite extensively. On one of the pages, the number of queries reached 84 (this includes application logic). With the changes from this PR, we have reduced this to 17.

The change in SettingsGroup 'caches' the AppSettings model, as getSettingsModel() is called in quite a few placed.

The change in TwillAppSettings loads the entire blocks relation into the model instead of creating a new query each time. Even when you have multiple sections within the same AppSettings, the blocks will only be loaded once.

The change in the AppSetting model is there in case someone wants to hook into the saved event of the AppSetting and expects to retrieve the new values. The same logic is in the test because technically the settings are updated in the same 'request' while the blocks were already loaded before the POST request.

Related Issues

This aims to solve the same problem as #2304

@ifox ifox merged commit f10733d into area17:3.x Nov 19, 2023
8 checks passed
@bonroyage bonroyage deleted the fix/settings-queries branch November 20, 2023 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants