Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 970561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:49:30+00:00 2026-05-16T02:49:30+00:00

Query 1: Top 10 codes that takes maximum time select top 10 source_code, stats.total_elapsed_time/1000000

  • 0

Query 1: Top 10 codes that takes maximum time

select top 10 
  source_code,
  stats.total_elapsed_time/1000000 as seconds,
  last_execution_time from sys.dm_exec_query_stats as stats
cross apply(SELECT 
              text as source_code 
            FROM sys.dm_exec_sql_text(sql_handle)) AS query_text
order by total_elapsed_time desc

Query2: Top 10 codes that takes maximum physical_reads

select top 10 
  source_code,
  stats.total_elapsed_time/1000000 as seconds,
  last_execution_time from sys.dm_exec_query_stats as stats
cross apply(SELECT 
              text as source_code 
            FROM sys.dm_exec_sql_text(sql_handle)) AS query_text
order by total_physical_reads desc

taken from this article

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:49:30+00:00Added an answer on May 16, 2026 at 2:49 am

    In MySQL you need to capture this information from a log file, and not via a query. Someone will probably tell you a query is possible, but they’re not being fair to you. See:

    http://dev.mysql.com/doc/refman/5.1/en/log-tables.html
    “Currently, logging to tables incurs significantly more server overhead than logging to files.”

    .. significant enough that if you are asking this question, you don’t want to use it.

    So now your question becomes “how do you do this with a log file?”. The number of physical reads for a query is not recorded in the stock-MySQL releases. It’s available in Percona Server though. The enhancement is awesome (even if I’m biased, I work for Percona):

    http://www.percona.com/docs/wiki/patches:slow_extended

    The next question becomes how do you aggregate the log so you can find these details. For that, I suggest mk-query-digest. http://www.maatkit.org/doc/mk-query-digest.html.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 490k
  • Answers 490k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Preemptively preventing these errors in the first place: 1) Turn… May 16, 2026 at 9:08 am
  • Editorial Team
    Editorial Team added an answer Take a look at this post. Also, make sure you're… May 16, 2026 at 9:08 am
  • Editorial Team
    Editorial Team added an answer pass the data of the extra fields as initial data… May 16, 2026 at 9:08 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I've written an SQL query that tells me the names of the previous week's
I have the following query That gets the city name, city id, the region
I have a query that uses a where clause. At times, this may be
I have a big query and I am tring to improve it part by
My scenario is this: I have a base NHibernate query to run of the
I'm using 2005 Windows Forms in C#. I've only been working at this for
Sorry about the length here. I'm using oscommerce and have a page with all
This is an SQL efficiency question. A while back I had to write a
I've made database design for a small CRM system. It comprises of Companies and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.