-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
enhancementNew feature or requestNew feature or request
Description
When one implements a SELECT
N+1 query how it manifests is that the same query (apart from the parameters) will be executed multiple times during page load. While not every duplicated query is a problem, we could add a feature to detect such queries and fail the given test.
Implementation notes
- An approach would be to use the Orchard Core Mini Profiler feature for this. A better one would be to implement our similar profiling logic with an
ISession
decorator to tap into the OC app since that wouldn't potentially break the UI (as the Mini Profile toolbar can). Perhaps it's possible to get the info out of Mini Profiler without showing the UI. - The initial implementation under OSOE-353: Add duplicate SQL query detector in Lombiq.UITestingToolbox #216 may be used for inspiration, but not the code directly.
- Common APIs for Consider implementing OpenTelemetry for Telmetry/Metrics OrchardCMS/OrchardCore#12251 can help here too.
Checklist
- Add per-test configurable count thresholds (that are kept for a given DI scope, so roughly an HTTP request) for the following:
- A SQL command is executed N times, regardless of its parameters. This can surface cases where instead of the same query being executed multiple times with different parameters you should rather have a single query that matches all desired rows.
- A SQL command is executed N times, but duplicates are only counted if the parameters are the same too. This can pinpoint cases where the result should be just cached.
- A SQL command's result set has more than N items. This can surface queries that lack appropriate filtering (and perhaps only filter in .NET instead of SQL).
- While the counting needs to happen in the Orchard Core app, the configurations and assertions (also when and how they're executed) should happen in the test project, following the patterns of accessibility checking and HTML validation.
- Add a heavily documented sample test that demonstrates all the basic capabilities of this feature to
Lombiq.Tests.UI.Samples
. - Add a documentation page about the feature and mention it as a highlight in the root Readme.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request