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

Question: Is it possible to cache the results of the query so it doesn't need to be rebuilt every time? #1

Open
jon49 opened this issue Jun 4, 2018 · 2 comments

Comments

@jon49
Copy link

jon49 commented Jun 4, 2018

I was wondering if it would be possible to cache the results of the SQL query so it doesn't need to be recompiled every time. I'm not sure if the performance boost on the client side would be worth it. But I would be surprised if it wasn't worth it.

Just an idea. I'm not sure how it would be implemented.

@brentmannering-zz
Copy link
Owner

Hi @jon49 thanks for the suggestion.

Just to clarify, you mean cache the generated SQL statement (e.g. SELECT ... FROM ...) for a given LINQ/Lambda expression?

Should be possible, I'll just need to figure out a way to verify the "uniqueness" of a query based on the expression tree... Run time variables might be a problem too, but I can try and have a go at it.

@jon49
Copy link
Author

jon49 commented Jun 5, 2018

Yes, I was thinking of the resulting SQL statement. It would be interesting to do perf tests on it first to see how fast your lib goes to begin with. I imagine it wouldn't be that fast since you have to do all the work just to get to the SQL Statement.

That is why I was wondering if it would be possible, or if it is even worth it.

Here's some bench marks that it could be based off of to see where Linq2Dapper resides:

https://github.com/MoonStorm/Dapper.FastCRUD#speed
https://github.com/StackExchange/Dapper#performance-of-select-mapping-over-500-iterations---poco-serialization

I was originally thinking of doing something like this:

private static object myqueryUniqueIdentifier = new object();
...
var thing =
    (from a in _connection.Query<ModelName>(myqueryUniqueIdentifier)
     where a.Id == 1
     select a).Single();

Maybe even use a JS-like Symbol object.

I'm not sure if there would be a more elegant way to do it in C#.

I wish I had more bandwidth to help out a lot more with this! Seems like a great project! Get the full static typing like other heavy projects but close to the perf Dapper! I would think that caching the result would get it really close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants