Does anyone have an information about a good query profiler?? By query i mean about 5 page search query.The profiler should be such as which gives the bottleneck in the query.
thanks
Depends on the database engine you use.
If it's Sybase, then use set statistics (io, time) and set queryplan on.
In MySQL, you can do EXPLAIN <query>. More approaches are in this blog entry: "MySQL Performance Monitoring and Optimization Tools".
In MS SQL Server use SQL Server Profiler.
For MySQL, you can use SQLyog's Query Profiler feature... SQLyog is very simple and easy to use MySQL GUI tool with loads of powerfull features... Hope it helps...
Related
I am a developer and performance tester but not a DBA. My team is working on a performance testing tool that is specific to our software. One of the features we want it to have is the ability to generate a database report immediately after the test. Our software is database agnostic. For Oracle, I can easily create a snapshot id before and after the test and programmatically create an AWR report for those snapshots, write to a file and save with other artifacts we gather. Works great.
For SQL Server, however, there is no AWR equivalent (that I know of). I know the MDW as part of the SSMS has a UI for getting things like top 10 slow SQL and things like that. But, I have not yet found a way to programmatically create and extract a SQL performance report (preferably similar to Oracle's AWR) for SQL Server.
I am even willing to create the report myself if I can find a way to extract the raw data.
Any ideas would be greatly appreciated because searching online is not getting me anywhere.
P.S. I'm trying to do this in Java, by the way, but will accept help in any language. Thanks again!
Good news! In SQL Server 2016, you can use Query Store. This is like your flight recorder blackbox.. finding long running queries and waits. Capture baseline built in to SQL Server. You can compare before and after hardware changes and/or upgrades on queries. Maybe this similar to Oracle AWR.
Only available SQL Server 2016 and up.
Are there any other tools out there that can analyze a SQL Profiler trace file and recommend indexes?
I highly recommend the free Qure Analyzer from DB Sophic:
http://www.dbsophic.com/qure-analyzer.html
Disclaimer: I work for SQL Sentry, who partners with DB Sophic on a paid version of their tools which work with our Performance Advisor product. This is not an attempt to up-sell, I am merely pointing you to a free tool that seems to meet your requirements.
You may also want to look at ClearTrace - it's not a one-for-one replacement for DTA, but it is quite useful if you're already collecting traces:
http://www.sqlmag.com/article/performance/cleartrace
If you are running SQL 2005 or higher you can use the Index Related DMVs. You can probably search Google for a handful of scripts using them.
How do I use SQL Server Tuning Advisor to produce recommendations based on Entity Framework queries? Entity Framework uses sp_executesql 'query' instead of executing the query and Tuning Advisor does not recognize these queries. I could get the query text manually, but this will only work for very simple scenarious. How do I do it in an automatic way?
UPDATE
Would it help if I save the profiling information into a table and then run some application which will strip "sp_executesql" and only keep the query text and use this new data to run Tuning Advisor?
I know this topic is a little cold. But since I was having the same issue and found a better solution:
Changing events captured is one way to do it, but there is already a "template", which records everything needed by the SQL server tuning advisor.
If you select the template "tuning", it will effectively remove and add event capture quoted by Doug, but another too.
You can find more about template here
To activate this template, in the "New Trace" windows, select the corresponding template( I didn't create it, it was already there):
Once you did it, you can check the event selection, you have already what is needed:
I additionaly disabled the RPCCompleted, since I've no stored procedure
I hope it will help some people ;)
It looks like the problem is this. If you create a trace using SQL Profiler from the "Tuning" template it does not include the correct events. The Database Engine Tuning Advisor does not understand sp_executsql statements from the batch completed events. It report in the tuning log "Event does not reference any tables" with a category ID of "S008".
When capturing your trace you need to add the "SQL:StmtCompleted" event under the TSQL section as well.
Jeff Walker pointed me in the right direction - but his answer was incomplete (although I'm certain he knew the complete answer and just didn't fully explain it)
In the Event Selection for Sql Server Profiler:
Remove the logging of RPC:Completed under Stored Procedures - this is the item that does poorly with Entity Framework
Expand to all events and ADD SP:StmtCompleted under Stored Procedure in order to get the queries into the trace.
Seems to work for me.
Microsoft Entity Framework People (and profiler people) This is actually lame. It used to work.
Use SQL Profiler to capture a whole session of queries. When you're done you can save the profiler results and run the whole thing through SQL Server Tuning Advisor. In my experience this gives much better results than tuning based on individual queries and in many ways is easier and more realistic since you can use profiler to capture queries from real application usage.
EDIT:
Thanks for bringing more attention to the specific issue you're asking about. I didn't realize you were saying that the Tuning Advisor doesn't understand sp_executesql because that simply isn't true. You can run as many queries as you want through sp_executesql and capture them in a profile and then run that profile through Tuning Advisor and it will give you recommendations.
To be sure, I just did it with MS SQL Server 2008 R2. I created a table with no indexes, ran a bunch of queries through sp_executesql, captured them in SQL Profiler, and then ran the resulting trace through Tuning Advisor. Tuning Advisor gave appropriate recommendations for the queries embedded within sp_executesql.
The exact version of Database Engine Tuning Advisor is 10.50.1600.1, running against Microsoft SQL Server 2008 R2 (RTM) - 10.50.1617.0 (X64) Apr 22 2011 19:23:43 Copyright (c) Microsoft Corporation Developer Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1).
Where can I find some in-depth information on tuning statistics in SQL Server 2005?
I need to really delve in to what statistics are being used in a number of different queries, how they are interacting with indexes, how/when/where to use custom statistics (over and above what the database tuning advisor recommends), when/how to update the statistics for the best performance etc. etc.
Does anyone know of any good articles/webcasts/books around this subject?
Thanks in advance,
Tom
This book gives fairly detailed information on performance tuning Inside Microsoft® SQL Server(TM) 2005: Query Tuning and Optimization
I suggest you review the following comprehensive Microsoft TechNet reference.
Statistics Used by the Query Optimizer
I suggest you visit http://sqlserverpedia.com/ and look for blog/article/demo/screencast/podcast specific to your needs. SQLServerPedia is a free Premier Online SQL Server resource.
Or are you specifically asking these questions right now:
"Why is this query running slow? Is my
index getting used? Why does this
query run faster than this query?"
The book "Dissecting SQL Server Execution Plans" will help you on this regard. A free ebook version is available here.
;-)
MarlonRibunal
It seems like the generation of SQL scripts from the SQL Server Management Studio is terribly slow. I think that the old Enterprise Manager could run laps around the newer script generation tool. I've seen a few posts here and there with other folks complaining about the speed, but I haven't seen much offered in the way of alternatives.
Is there a low-cost/free tool for scripting an entire SQL Server 2005 database that will perform better that SSMS? It would be hard to do worse.
See the Database Publishing Wizard that is part of the SQL Server Hosting Toolkit. It generates a single SQL file for both schema and data.
We are using the tools by RedGate which I personally find very useful in any aspect of work with databases. For scripting I would recommend the SQL Compare (you need a pro version for scripting). The SQL Compare is a must have for deploying schema changes from the deployment DB to the live Server and a real timesaver.
Those tools are not free but I think they could save you money in a long run
What kind of scrpt generation are you talking about now?, generating create scripts from the objects in the database is way faster in SSMS compared to EM.
But if you are running an select or something that gives you lots of rows in the grid, it is crazy slow.. like scripts generating inserts statements of all rows in an table, if you got lots of data, it is almost not doable.
I don't know what is "terribly slow" for you, but I have a decent performance with SQL 2005 Management Studio. In either case, RedGate products are very cool. Unfortunately they are not free.