Question

MiniProfiler detects "duplicate" SQL queries and gives you a red exclamation mark in the corner when it detects them (I'm using MiniProfilerEF to link in to my code-first EF database access). This is often very useful, but sometimes these duplicate queries are fully justified, like say when I'm updating 50 users in a parametrized way; 49 are going to be detected as duplicate queries.

Is there a way, then, for me to disable this duplicate SQL query detection for a block of code? Something like:

using (MiniProfiler.Current.Step("Do bulk updates"), Options.NoDuplicateSqlChecking) {
    // ...
}

... would be good.

Looking at the MiniProfiler code, this line seems to be checking for duplicates:
https://github.com/SamSaffron/MiniProfiler/blob/master/StackExchange.Profiling/MiniProfiler.IDbProfiler.cs#L91

Doesn't look like there's any way to do this at the moment. I guess stats.IsDuplicate would never have to be set to true if this option were specified, but it's tricky only doing it for a particular block of code. Alternatively maybe the parameters as well as the SQL command string could be taken into account somehow, as they are likely to change, even with bulk operations.

Was it helpful?

Solution

Just found the answer to my own question; you can use MiniProfiler.Current.Ignore() to stop profiling of certain sections of code:

using (MiniProfiler.Current.Ignore()) {
    // ...
}

This pretty much does what I want; the only slight annoyance is that it stops profiling altogether. I'd rather it kept listing the SQL queries but didn't label them as duplicates, but oh well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top