SQLAuthority News – Ahmedabad SQL Server User Group Meeting Review – March 21, 2009

We had fun session with Ahmedabad SQL Server Usre Group last week on March 21, 2009. It was short session but one interesting one. We discussed about how query profiler works and how to find most popular query from SQL Server instance. We had also prepared Trace Template as well query which can ran to identify longest running query along with popular query. I received nearly 10 questions after my session and lots of time was spent answering them. The whole session was very interactive. Here is my short user group meeting review for those who missed it.

To close this user group meeting review, I want to congratulate everybody who attended it, if you need my Profiler Template and Query to identify longest running query as well popular query, please let me know and I will send them to you.

Ahmedabad SQL User Group Meeting.

SQL profiler tools presentation.

Finding Popular and Slow Queries Today

In 2009, SQL Profiler and a trace template were the standard way to catch the longest running and most popular queries. Profiler is now deprecated for the database engine. Today I use Extended Events for tracing, and Query Store, which arrived in SQL Server 2016, to see query history over time. The tools changed, but the goal is the same. For a quick look, the plan cache DMVs still answer the question we discussed that evening.

SELECT TOP 10
    qs.execution_count,
    qs.total_elapsed_time / qs.execution_count AS avg_elapsed_time,
    st.text AS query_text
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st
ORDER BY qs.execution_count DESC;

Sort by execution_count to find the popular queries, or by total_elapsed_time to find the ones that cost the most time overall. Keep in mind that these numbers reset when SQL Server restarts or when a plan leaves the cache. That was the heart of this user group meeting review, and the idea still holds up well.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL Profiler, SQL User Group, SQLAuthority Author Visit
Previous Post
SQLAuthority News – Author Visit – South Asian MVPs at Global MVP Summit 2009
Next Post
SQLAuthority News – Author Video Interview Published Online – Microsoft MVP Summit 2009

Related Posts

5 Comments. Leave new

  • Hi Pinal,

    I have seen your website and you have started meeting in Ahmadabad.
    That’s very good news for our gujarat IT eng.
    in your meeting you had a great fun with knowledge shared with each others member . I see on this post and I am happy to see your meeting photo………:) all are looking good. :)

    I have one suggestion…..Please record video of your meetup and upload in youtube and share that video with all groups member who are not able to attend meeting. for some reason.

    Have a great day !

    Regards,
    Shailesh Kavathiya

    Reply
  • Sir,

    Many people loves you very much. We have big fan base here in B’lore.

    Come down here and we will have big event ready for you.
    Do not publish my name. Email for you only.

    Your Big Fan

    Reply
  • Can you tell me what is the use of ROLLUP keyword. can we use it practically.

    Ex.

    SELECT SC.CustomerID,
    SUM( soh.TaxAmt) AS TotalTax_Amount,
    GROUPING(SC.CustomerID) AS ‘Grouping1’,
    GROUPING(soh.TaxAmt) AS ‘Grouping2’

    FROM Sales.Customer SC
    INNER JOIN Sales.SalesOrderHeader soh
    ON SC.CustomerID = soh.CustomerID
    GROUP BY SC.CustomerID,soh.TaxAmt
    WITH rollup

    **
    why doesn’t the Grouping1 coloumn gives 1 when customerID change.

    Reply
  • Will you be able to send me your Profiler Template and Query to identify Longest running query?

    It will be a great help from your side to resolve my high connection as welll as deadlock issues.

    Thanks in advance
    Sneha Shah

    Reply
  • Atin Srivastava
    August 5, 2009 3:51 pm

    Hi
    Can u plz send the Profiler template and query to identify longest running query??

    Thanx a lot in advance

    Atin

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.