Home > Software design >  How to find location in database of CPU intensive query?
How to find location in database of CPU intensive query?

Time:02-08

I have a server called "Reporting" and looking at SQL Server performance reports, specifically "Top Queries by Total CPU Time". I have found the top CPU Time consuming queries.

The number 1 query shows me the "Query Text", "Database Name", "Object ID" and "Total CPU Time".

I would like to go and optimize the code of that query but I only know the database where the query is from but not the exact location folder or name of the query.

Is there any way of how one can go about finding the exact name and location of the query?

 For Example:
Top CPU Expensive Query is in Database "Training", ObjectID "1727285326", Query text  - 500 lines of SQL code. 
Where do I go look in the "Training" Database for the query since I only see the Query Text and Object ID?

Any help or right direction would be much appreciated.

CodePudding user response:

As you have the object id you can just use the following to find the object

USE Training;

SELECT OBJECT_SCHEMA_NAME(1727285326) AS schema_name,
       OBJECT_NAME(1727285326)        AS object_name; 
  •  Tags:  
  • Related