Is there any tool that will inspect either asp.net or sql server and report all the queries that are run against the database? The reason I ask is I am using Linq for a project and want to double check what its actually doing for each page.
是否有任何工具可以检查asp.net或sql server并报告针对数据库运行的所有查询?我问的原因是我正在使用Linq进行项目,并希望仔细检查它对每个页面的实际操作。
Ideally I'd like to view a page in a browser and have a report of all the queries that were run to create that page.
理想情况下,我想在浏览器中查看页面,并报告为创建该页面而运行的所有查询。
I know I can view the SQL it runs for individual queries using debugging/breakpoints, and I know about LinqPad, but I'm afraid Linq is making several more queries on its own to get related data that I may not be directly aware of. Is there anything (tool/program/report/etc) like what I described? Thanks!
我知道我可以使用调试/断点查看它为单个查询运行的SQL,我知道LinqPad,但我担心Linq自己会再提出几个查询来获取我可能不会直接知道的相关数据。有什么(工具/程序/报告/等)像我描述的那样吗?谢谢!
EDIT: Is there any FREE tool that can do this? I am using Sql Server 2008 Express and don't have SQL Profiler unfortunately.
编辑:有没有可以做到这一点的免费工具?我使用的是Sql Server 2008 Express,但遗憾的是没有SQL Profiler。
7 个解决方案
#1
14
Absolutely, There is a SQL tool called SQL Profiler. It does require elevated database permissions in order to run profiler.
当然,有一个名为SQL Profiler的SQL工具。它确实需要提升的数据库权限才能运行探查器。
There is a decent tutorial on how to run Profiler on TechRepublic.
有一个关于如何在TechRepublic上运行Profiler的体面教程。
Another option out there is the NHibernate Profiler. I know that it is not as "free" as SQL Profiler, have never used it, but the screen shots for it look pretty cool.
另一个选择是NHibernate Profiler。我知道它不像SQL Profiler那样“免费”,从未使用它,但它的屏幕截图看起来很酷。
#2
3
Profiler is the best tool of them all for this but it can be expensive in inexperienced hands.
Profiler是他们所有人的最佳工具,但在经验不足的手中它可能很昂贵。
You can also try to do "exec sp_who" and then a "dbcc inputbuffer (111)" - just put the process id in the place of 111.
您也可以尝试执行“exec sp_who”然后尝试“dbcc inputbuffer(111)” - 只需将进程ID放在111的位置即可。
#4
1
Since you are using SQL Server Express, how about this tool?
由于您使用的是SQL Server Express,这个工具怎么样?
Profiler for Microsoft SQL Server 2005/2008 Express Edition
适用于Microsoft SQL Server 2005/2008 Express Edition的Profiler
Microsoft SQL Server family includes free Express edition, that is fully functional, however has some disappointing limitations which prevent from using it in development process. One of them is absense of profiling tools, standard SQL profiler is not included. However, now you have an ability to use express edition for tuning your system. SQL Server Express Edition Profiler provides the most of functionality standard profiler does, such as choosing events to profile, setting filters, etc. By now there are no analogue free tools.
Microsoft SQL Server系列包括免费的Express版本,该版本功能齐全,但有一些令人失望的限制,无法在开发过程中使用它。其中一个是缺少分析工具,不包括标准SQL分析器。但是,现在您可以使用快速版本来调整系统。 SQL Server Express Edition Profiler提供了标准分析器所具有的大部分功能,例如选择要分析的事件,设置过滤器等。到目前为止,还没有模拟免费工具。
#5
1
A quick and dirty way to log LINQ to SQL queries in ASP.NET is this (assuming a Northwind.Dbml):
在ASP.NET中记录LINQ to SQL查询的快速而又脏的方法是这样的(假设是Northwind.Dbml):
NorthwindDataContext context = new NorthwindDataContext();
context.Log = Response.Output;
This will write all queries to the response stream. Nasty, but handy for instant gratification without need for debuggers or profilers etc.
这会将所有查询写入响应流。讨厌,但不需要调试器或分析器等即时满足即时满足
#6
0
For the LINQ to SQL queries specifically, you can also use the DataContext.Log
property to output the queries to a TextWriter
, so you can do things like write to debugger output window or (as in my use) to log4net.
具体来说,对于LINQ to SQL查询,您还可以使用DataContext.Log属性将查询输出到TextWriter,这样您就可以执行诸如写入调试器输出窗口或(如我的使用中)到log4net的操作。
These links might help:
这些链接可能有所帮助
- Log to debugger output window, file, or memory
- Log to log4net
记录到调试器输出窗口,文件或内存
登录log4net
Won't cover the stuff not generated by L2S, so this may not be the end all solution for you... but I've found it helpful.
不会涵盖L2S不会产生的东西,所以这对你来说可能不是最终的解决方案......但我发现它很有帮助。
#7
0
This one is only free for the first 45 days, but it gives you runtime profiling/logging with a bunch of filter options, SQL Server query execution plan logging etc. Built specifically for profiling L2S apps:
这个版本仅在前45天免费,但它为您提供运行时分析/日志记录,其中包含一系列过滤器选项,SQL Server查询执行计划日志记录等。专门用于分析L2S应用程序:
#1
14
Absolutely, There is a SQL tool called SQL Profiler. It does require elevated database permissions in order to run profiler.
当然,有一个名为SQL Profiler的SQL工具。它确实需要提升的数据库权限才能运行探查器。
There is a decent tutorial on how to run Profiler on TechRepublic.
有一个关于如何在TechRepublic上运行Profiler的体面教程。
Another option out there is the NHibernate Profiler. I know that it is not as "free" as SQL Profiler, have never used it, but the screen shots for it look pretty cool.
另一个选择是NHibernate Profiler。我知道它不像SQL Profiler那样“免费”,从未使用它,但它的屏幕截图看起来很酷。
#2
3
Profiler is the best tool of them all for this but it can be expensive in inexperienced hands.
Profiler是他们所有人的最佳工具,但在经验不足的手中它可能很昂贵。
You can also try to do "exec sp_who" and then a "dbcc inputbuffer (111)" - just put the process id in the place of 111.
您也可以尝试执行“exec sp_who”然后尝试“dbcc inputbuffer(111)” - 只需将进程ID放在111的位置即可。
#3
#4
1
Since you are using SQL Server Express, how about this tool?
由于您使用的是SQL Server Express,这个工具怎么样?
Profiler for Microsoft SQL Server 2005/2008 Express Edition
适用于Microsoft SQL Server 2005/2008 Express Edition的Profiler
Microsoft SQL Server family includes free Express edition, that is fully functional, however has some disappointing limitations which prevent from using it in development process. One of them is absense of profiling tools, standard SQL profiler is not included. However, now you have an ability to use express edition for tuning your system. SQL Server Express Edition Profiler provides the most of functionality standard profiler does, such as choosing events to profile, setting filters, etc. By now there are no analogue free tools.
Microsoft SQL Server系列包括免费的Express版本,该版本功能齐全,但有一些令人失望的限制,无法在开发过程中使用它。其中一个是缺少分析工具,不包括标准SQL分析器。但是,现在您可以使用快速版本来调整系统。 SQL Server Express Edition Profiler提供了标准分析器所具有的大部分功能,例如选择要分析的事件,设置过滤器等。到目前为止,还没有模拟免费工具。
#5
1
A quick and dirty way to log LINQ to SQL queries in ASP.NET is this (assuming a Northwind.Dbml):
在ASP.NET中记录LINQ to SQL查询的快速而又脏的方法是这样的(假设是Northwind.Dbml):
NorthwindDataContext context = new NorthwindDataContext();
context.Log = Response.Output;
This will write all queries to the response stream. Nasty, but handy for instant gratification without need for debuggers or profilers etc.
这会将所有查询写入响应流。讨厌,但不需要调试器或分析器等即时满足即时满足
#6
0
For the LINQ to SQL queries specifically, you can also use the DataContext.Log
property to output the queries to a TextWriter
, so you can do things like write to debugger output window or (as in my use) to log4net.
具体来说,对于LINQ to SQL查询,您还可以使用DataContext.Log属性将查询输出到TextWriter,这样您就可以执行诸如写入调试器输出窗口或(如我的使用中)到log4net的操作。
These links might help:
这些链接可能有所帮助
- Log to debugger output window, file, or memory
- Log to log4net
记录到调试器输出窗口,文件或内存
登录log4net
Won't cover the stuff not generated by L2S, so this may not be the end all solution for you... but I've found it helpful.
不会涵盖L2S不会产生的东西,所以这对你来说可能不是最终的解决方案......但我发现它很有帮助。
#7
0
This one is only free for the first 45 days, but it gives you runtime profiling/logging with a bunch of filter options, SQL Server query execution plan logging etc. Built specifically for profiling L2S apps:
这个版本仅在前45天免费,但它为您提供运行时分析/日志记录,其中包含一系列过滤器选项,SQL Server查询执行计划日志记录等。专门用于分析L2S应用程序: