Skip to content

Query: SelectExpression Cache hit for InExpression coming from parameter #12777

@smitpatel

Description

@smitpatel

Currently when we have Enumerable.Contains in SelectExpression, the Enumerable comes in as a parameter and we generate a list of constant for InExpression. This means for each parameter we have to generate different SQL. (No second level query caching).

According to the idea from @divega,

Instead of putting a list of constant which would change every time, we can put a list of parameters in fixed number (let's say 10) and generate 1 SelectExpression. If the Enumerable has 10 elements then we just set parameter values and use SelectExpression from cache. If enumerable has lesser than 10 elements then we can copy the last value in remaining parameters just to fill in the values (it would have no effect on results). In case if the Enumerable has more than 10 elements then we can generate SelectExpression of higher number of params in InExpression or just use it without caching like we do today.

This could give us performance boost especially when SQL is large. Though at the same time plumbing of cache key would be slight complex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions