How can I stop MiniProfiler showing "duplicate" SQL query alert parameters?

I am using MiniProfiler to test what NPoco is doing with SQL Server, but I noticed that it sends duplicate queries even though the SQL parameters have different values.

For example: if I get a string from the database by ID, I can call:

SELECT * FROM PageContent WHERE ID=@ID

... twice on the same page with two different IDs, but MiniProfiler reports this as a duplicate request, although the results will of course be different.

Is there any way I can get MiniProfiler to respect the values ​​of the SQL parameters so that it doesn't think these queries are duplicated? I'm not sure if this issue is part of the MiniProfiler, or if it is a problem with the way NPoco communicates its actions to the MiniProfiler, so I'll note both.

+3


source to share


1 answer


I think this is by design and is actually one of the reasons for duplicate requests.

If you run this query twice on the same page where the only difference is the parameter value, you can also run it once and include both parameter values ​​in this query.

SELECT * FROM PageContent WHERE ID in (@ID1, @ID2)

      



So you do with two requests, which you can do with one (you will of course have to filter on the server side, but that's faster than two requests).

A repeatable query label does not mean that you are running an absolutely identical query more than once (although it will apply there too). Rather, it emphasizes the possibility of optimizing your query approach and combining different queries into one (think about what the N + 1 situation would look like).

If the default function doesn't meet your needs, you can always change it! The functionality that calculates duplicateTimings is in UI / includes.js . You can provide your own version of this file that defines duplicates differently (perhaps by looking at parameter values ​​in addition to the command text if duplicates are found) by including CustomUITemplates

inside MiniProfiler and placing your own version of include.js there.

+2


source







All Articles