yodeski / mvc-mini-profiler

Automatically exported from code.google.com/p/mvc-mini-profiler
0 stars 0 forks source link

query time column always reads 0.0ms #69

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  I'm running a typical .NET 4.0 WebForms application with the recommended 
mvc-mini-profiler setup.  Starting the profiler for Local Requests only.

What is the expected output? What do you see instead?
Below is a sample of what I see:
duration (ms)   from start (ms)     query time (ms)
6.3     +0.0
  Assemble criteria and run GetData_SearchXML   0.7     +1.9
   Get stored procedure data    554.3   +2.1    1 sql   0.0
  Get page range and run GetData_ResultsXML     16.2    +557.0  1 sql   0.0
  Serialize marked results  0.0     +573.3
  Initialize all page controls  0.2     +573.4

The database connection factory is correctly wrapped and I can see all the SQL 
that gets executed, along with the T+ offsets from the beginning of the 
profile.  The Reader, however, always shows 0.0ms.  I attempted to use 
MiniProfiler.Current from my Database class which is in a separate .NET dll.  I 
also attempted to pass in MiniProfiler.Current from the calling code after the 
database object was created.

What version of the product are you using? On what operating system?
Latest 1.6 on IIS 7.5 under Win7 x64.

Please provide any additional information below.

When step-through debugging, it appears that MiniProfiler.Current has the 
correct values within the database object.  When executing DbDataReader dr = 
cmd.ExecuteReader();, the SqlTimings property changes from false to true.

Original issue reported on code.google.com by andyp...@gmail.com on 25 Jul 2011 at 9:42

GoogleCodeExporter commented 9 years ago
have you walked all the results the proc returns ? 

Original comment by sam.saff...@gmail.com on 26 Jul 2011 at 1:46

GoogleCodeExporter commented 9 years ago
I believe the answer to that is yes.  I have to call a method to map the 
DataReader to a DataSet to retrieve the rowcount as well as maintain 
compatibility with my DB class and method signatures, and that method does run 
through and reconstruct all the results row by row.

Would that affect the sql timing?

Original comment by andyp...@gmail.com on 26 Jul 2011 at 1:57

GoogleCodeExporter commented 9 years ago
I had a similar issue to this.  In had to always create the command from the 
connection. I.e.

This did NOT work:

var cmd = new SqlCommand();
cmd.Connection = conn;

This DID work:

var cmd = conn.CreateCommand();

Original comment by mbol...@gmail.com on 28 Jul 2011 at 6:23

GoogleCodeExporter commented 9 years ago
Yep.  I'm already using DbCommand cmd = conn.CreateCommand();

Original comment by andyp...@gmail.com on 28 Jul 2011 at 9:25

GoogleCodeExporter commented 9 years ago
@andy, yeah ... if you partially walk results timing is skewed

Can you include a full bit of demo code here so I an repro? 

Original comment by sam.saff...@gmail.com on 29 Jul 2011 at 12:00

GoogleCodeExporter commented 9 years ago
Sure.  Here's a web project that reproduces the problem exactly.  I got it down 
to just over 100 lines so it should be pretty easy for you to scan through.

Original comment by andyp...@gmail.com on 29 Jul 2011 at 9:12

Attachments:

GoogleCodeExporter commented 9 years ago
@andy - does it change anything if you set the sqlCommand.commandtype to stored 
proc? I noticed it wasn't being set.

Original comment by woodward...@gmail.com on 5 Aug 2011 at 2:58

GoogleCodeExporter commented 9 years ago
The command passed is not actually a stored procedure.  It's a sql exec 
statement that runs a stored procedure.  I'm not explicitly passing in 
parameters or anything like that in my db class.  It's not ideal, but I just 
did it that way and gave up a little bit of safety for a lot of flexibility in 
what I could run.

Original comment by andyp...@gmail.com on 5 Aug 2011 at 3:20

GoogleCodeExporter commented 9 years ago
Andy, I have exact same issue, when I'm executing a reader on the a stored 
procedure command type. and it is marked as command.CommandType = 
CommandType.StoredProcedure;

Original comment by mercury2...@gmail.com on 5 Jun 2012 at 7:09