Skip to content

Conversation

dazinator
Copy link

No description provided.

@dazinator
Copy link
Author

dazinator commented Oct 5, 2022

@StefanTheCode - Thanks for the challenge!
Perhaps I am the first to use FromSqlRaw? This seems to be a recommended approach when EF just isn't capable of cutting the mustard. My whole approach here is about minimizing EF involvement whilst still using approved api's. In that sprit I am also not using LINQ (just a couple of for loops) over a flattened result set which builds and returns the result dto's in one single iteration of the data / rows from the db.

Interestingly I only see an approx 229.75x faster improvement. Memory usage is drastically better - and could be made better by modying the dto's returned to remove redundant fields no doubt, but I wasn't sure if this was allowed. I also have a few other ideas but given speed is the goal and not memory usage I won't pursue them.

image

I believe I have adhered to the rules in that I have treated the DbContext and entities as unmodifiable / third party code. I have derived my own dbcontext in order to extend the model to include a keyless entity which is - I feel a valid technique, as it is purely additive and makes no changes to the original models or schema, so assuming the original dbcontext and entities were shipped to me in a non modifiable assembly, this is a valid approach!

@dazinator
Copy link
Author

Ran it again and it says 234 times improvement!

image

@dazinator dazinator changed the title Is this cheeting? Is this cheeting? (234x improvement) Oct 5, 2022
@dazinator
Copy link
Author

Assuming it is ok to trim the dto's returned I can make it a tiny bit faster (237x vs 234x) - have just pushed that commit.

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.

1 participant