Skip to content

Add duplicate SQL query detector (OSOE-353) #93

@Piedone

Description

@Piedone

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

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.

Jira issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions