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

Add RelationalCommandCaching based on parameter value nullability #18035

Merged
merged 1 commit into from
Oct 21, 2019

Conversation

smitpatel
Copy link
Member

@smitpatel smitpatel commented Sep 25, 2019

Resolves #15892

I attempted to add to cosmos also but ran into #18033
Currently this takes naïve approach that if SelectExpression was modified during parameter based EV then we cannot cache it. If we work on #16375 then that would be quite accurate logic without us having to pass back the information. I filed #18034 to track.

@smitpatel
Copy link
Member Author

Implementation follows what we had in previous versions.

@AndriySvyryd
Copy link
Member

Tests?

@smitpatel
Copy link
Member Author

Do you have any ideas in mind, how to test this? A way to catch regression would be our perf tests.

@AndriySvyryd
Copy link
Member

You can add unit tests with a mock QuerySqlGenerator and assert how many times a command was created.

@AndriySvyryd
Copy link
Member

We should also consider extracting some nested classes out of the partial classes. The fact that they are partial is a smell and it's ok to have a separate type even if it's only used in one place.

@smitpatel
Copy link
Member Author

smitpatel commented Sep 27, 2019

They are implementation detail of this visitor hence stayed inside. Is partial the issue or nesting?

@AndriySvyryd
Copy link
Member

@smitpatel The partial means that the class is too big and should be split. And in practice you don't gain much by keeping the class nested.

@smitpatel smitpatel force-pushed the somethingfuntodo branch 2 times, most recently from 7da3faf to 7db14d5 Compare September 30, 2019 22:27
@smitpatel
Copy link
Member Author

@AndriySvyryd - Since this is also cache, do we need to do anything specific for cache eviction?

@smitpatel smitpatel changed the base branch from somethingfuntodo to release/3.1 September 30, 2019 22:36
@AndriySvyryd
Copy link
Member

@smitpatel Yes, use MemoryCache and set size for the entries

@smitpatel
Copy link
Member Author

Filed #18493 for tests

@smitpatel smitpatel merged commit 9d4e349 into release/3.1 Oct 21, 2019
@smitpatel smitpatel deleted the smit/whereareyouhiding branch October 21, 2019 23:15
{
private class RelationalCommandCache
{
private readonly ConcurrentDictionary<CommandCacheKey, IRelationalCommand> _commandCache
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use MemoryCache

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I was missing something. 😄

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.

Query: Add caching of generated RelationalCommand based on nullability of parameters
3 participants