Skip to content

Matcher to test that a query is covered by an index (covered query) #238

Open
@Startouf

Description

@Startouf

Would it be possible to make make a matcher to ensure that a given request is a covered query ?

We could take advantage of mongodb's explain feature to check this.

I have written some basic tests that make sure the winning plan relies on an IXSCAN, I believe it would be possible to build more advanced matchers based on this ?

I know it mainly depends on what data you need to retrieve, but it could prove very useful to ensure the code is fast.
Note that it may be slightly more difficult for special queries like count

let(:winning_plan) { criteria.explain.dig('queryPlanner', 'winningPlan') }
expect(winning_plan).to include('stage' => 'IXSCAN')

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions