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

InlineFormatter is very slow for large queries #629

Open
Bouke opened this issue Nov 30, 2022 · 2 comments
Open

InlineFormatter is very slow for large queries #629

Bouke opened this issue Nov 30, 2022 · 2 comments

Comments

@Bouke
Copy link
Contributor

Bouke commented Nov 30, 2022

I was debugging a performance issue with some bulk operation. On a hunch I turned off MiniProfiler and the performance difference was night and day. The total time spent in the operation dropped from 102 to 13 seconds, with ~6 seconds spend on the 19 sql operations (consisting of many insert/update).

After doing some profiling I found that all of MiniProfiler's time was spent in InlineFormatter:

I turned the formatting (mostly) off by setting options.SqlFormatter = null. Now I still get sql timings, but without all the work related to the formatting. I'm using MiniProfiler here in a command line utility and am only interested in the timings and not even looking at (un)formatted sql.

MiniProfiler.EntityFrameworkCore: 4.2.22

@NickCraver
Copy link
Member

Do you have an example query? Inline is not the default because it may even mess up a few more complicated queries (you simply can't do everything in-line that could be a parameter, it's a different superset). How big of a SQL string are we talking here? We can definitely look at optimizing, just hasn't come up before with numbers being that small and usage being relatively rare.

@0Lucifer0
Copy link

I can confirm this.
582035 character in my pgsql query (lots of arguments) takes 90s without options.SqlFormatter = null instead of 5 seconds with it

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

No branches or pull requests

3 participants